无法解析符号altbeacon



大家好!我是android开发的新手,我有一个困惑。我试图与iBeacons(大学项目(合作,但我遇到了以下问题。它一直在说:";无法解析符号altbeacon";。

我已经添加了这行

implementation 'org.altbeacon:android-beacon-library:2+'

根据官方指示https://altbeacon.github.io/android-beacon-library/configure.html

但我不明白我应该把这个放在哪里

repositories {
mavenCentral()
}

这是我的等级文件

plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.tarsiusv1"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation files('libs/gradle-wrapper.jar')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'org.altbeacon:android-beacon-library:2+'
}

该android页面的完整代码。


import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.Identifier;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import java.util.Locale;

public class MainActivity extends AppCompatActivity implements BeaconConsumer, RangeNotifier{
private Button navigationSystem;
private Button helpSystem;
private Button emergencySystem;
private Button newsSystem;
private TextToSpeech tts;
private String destinationLocation;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
tts.setLanguage(Locale.UK);
}
}
});
navigationSystem = findViewById(R.id.navigationSystemButton);
emergencySystem = findViewById(R.id.emergencySystemButton);
newsSystem = findViewById(R.id.newsSystemButton);
helpSystem = findViewById(R.id.helpSystemButton);
navigationSystem.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
openNavigationSystemActivity();
}
});
emergencySystem.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
openEmergencySystemActivity();
}
});
newsSystem.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
openNewsSystemActivity();
}
});
helpSystem.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
openHelpSystemActivity();
}
});
}
public void openHelpSystemActivity(){
Intent intent = new Intent(this, HelpSystem.class);
startActivity(intent);
}
public void openNavigationSystemActivity(){
speak();
}
public void openEmergencySystemActivity(){
Intent intent = new Intent(this, EmergencyActivity.class);
startActivity(intent);
}
public void openNewsSystemActivity(){
String urlStr = "https://www.youtube.com/c/NBCNews/videos";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(urlStr));
startActivity(intent);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 100 && resultCode == RESULT_OK){
destinationLocation = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).get(0);
//Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Uri gmmIntentUri = Uri.parse("google.navigation:q="+destinationLocation+"&mode=w");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
}
}
public void speak(){
// voice message
String speech = "Choose the location you want to go";
tts.speak(speech, TextToSpeech.QUEUE_FLUSH,null);
//waiting for the user voice input
Intent speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Start speaking" );
startActivityForResult(speechIntent, 100);
}

}

我发现了问题。以前我启用了";切换离线模式";在渐变窗口中。我禁用了它。

我还更改了这个:

implementation 'org.altbeacon:android-beacon-library:2+'

implementation 'org.altbeacon:android-beacon-library:2.19'

最新更新