MapBox Place Picker 导致 Fatal signal 6
MapBox Place Picker leads to Fatal signal 6
我正在按照这些说明尝试实现此 Place Picker
但是我的应用程序每次启动时都会崩溃并出现以下错误:A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL)
我该如何解决?我没有在网上找到解决方案...即使我发现 GitHub 问题也有同样的错误,但没有答案。有人可以帮忙吗?
这是我的代码:
public class PlaceSelectionPluginActivity extends AppCompatActivity {
private static final int REQUEST_CODE = 5678;
private TextView selectedLocationTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(this, "***myToken***");
setContentView(R.layout.activity_place_selection);
selectedLocationTextView = findViewById(R.id.selected_location_info_textview);
goToPickerActivity();
}
/**
* Set up the PlacePickerOptions and startActivityForResult
*/
private void goToPickerActivity() {
startActivityForResult(
new PlacePicker.IntentBuilder()
.accessToken("***myToken***")
.placeOptions(PlacePickerOptions.builder()
.statingCameraPosition(new CameraPosition.Builder()
.target(new LatLng(40.7544, -73.9862)).zoom(16).build())
.build())
.build(this), REQUEST_CODE);
}
/**
* This fires after a location is selected in the Places Plugin's PlacePickerActivity.
* @param requestCode code that is a part of the return to this activity
* @param resultCode code that is a part of the return to this activity
* @param data the data that is a part of the return to this activity
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_CANCELED) {
// Show the button and set the OnClickListener()
Button goToPickerActivityButton = findViewById(R.id.go_to_picker_button);
goToPickerActivityButton.setVisibility(View.VISIBLE);
goToPickerActivityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goToPickerActivity();
}
});
} else if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
// Retrieve the information from the selected location's CarmenFeature
CarmenFeature carmenFeature = PlacePicker.getPlace(data);
// Set the TextView text to the entire CarmenFeature. The CarmenFeature
// also be parsed through to grab and display certain information such as
// its placeName, text, or coordinates.
if (carmenFeature != null) {
selectedLocationTextView.setText(String.format(
getString(R.string.selected_place_info), carmenFeature.toJson()));
}
}
}
}
build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级别 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.mycompany.placepickertest"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.12.0'
}
activity_place_selection.xml
:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/go_to_picker_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible"
android:text="go to picker activity" />
<TextView
android:id="@+id/selected_location_info_textview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
完整堆栈跟踪:
2020-05-17 01:00:57.244 14576-14628/com.mycompany.mapboxpickerattempt I/oxpickerattemp: --------- beginning of crash
2020-05-17 01:00:57.265 14576-14628/com.mycompany.mapboxpickerattempt A/libc: /usr/local/google/buildbot/src/android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type jni::PendingJavaException" failed
2020-05-17 01:00:57.265 14576-14628/com.mycompany.mapboxpickerattempt A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14628 (OnlineFileSourc), pid 14576 (oxpickerattempt)
看来您基本上已经复制粘贴了这个示例,它应该可以工作:https://docs.mapbox.com/android/plugins/examples/place-picker/
能否请您分享应用程序级别 build.gradle 和项目级别 build.gradle,以及您的 activity_place_selection.xml?
能否将项目级别 build.gradle 更改为 link mapbox:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
这似乎需要 Java 8 声明。请将以下行添加到您的 build.gradle(应用程序级别):
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
这是我的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.placepicker"
minSdkVersion 24
targetSdkVersion 29
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 fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.12.0'
}
我正在按照这些说明尝试实现此 Place Picker
但是我的应用程序每次启动时都会崩溃并出现以下错误:A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL)
我该如何解决?我没有在网上找到解决方案...即使我发现 GitHub 问题也有同样的错误,但没有答案。有人可以帮忙吗?
这是我的代码:
public class PlaceSelectionPluginActivity extends AppCompatActivity {
private static final int REQUEST_CODE = 5678;
private TextView selectedLocationTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(this, "***myToken***");
setContentView(R.layout.activity_place_selection);
selectedLocationTextView = findViewById(R.id.selected_location_info_textview);
goToPickerActivity();
}
/**
* Set up the PlacePickerOptions and startActivityForResult
*/
private void goToPickerActivity() {
startActivityForResult(
new PlacePicker.IntentBuilder()
.accessToken("***myToken***")
.placeOptions(PlacePickerOptions.builder()
.statingCameraPosition(new CameraPosition.Builder()
.target(new LatLng(40.7544, -73.9862)).zoom(16).build())
.build())
.build(this), REQUEST_CODE);
}
/**
* This fires after a location is selected in the Places Plugin's PlacePickerActivity.
* @param requestCode code that is a part of the return to this activity
* @param resultCode code that is a part of the return to this activity
* @param data the data that is a part of the return to this activity
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_CANCELED) {
// Show the button and set the OnClickListener()
Button goToPickerActivityButton = findViewById(R.id.go_to_picker_button);
goToPickerActivityButton.setVisibility(View.VISIBLE);
goToPickerActivityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goToPickerActivity();
}
});
} else if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
// Retrieve the information from the selected location's CarmenFeature
CarmenFeature carmenFeature = PlacePicker.getPlace(data);
// Set the TextView text to the entire CarmenFeature. The CarmenFeature
// also be parsed through to grab and display certain information such as
// its placeName, text, or coordinates.
if (carmenFeature != null) {
selectedLocationTextView.setText(String.format(
getString(R.string.selected_place_info), carmenFeature.toJson()));
}
}
}
}
build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级别 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.mycompany.placepickertest"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.12.0'
}
activity_place_selection.xml
:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/go_to_picker_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible"
android:text="go to picker activity" />
<TextView
android:id="@+id/selected_location_info_textview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
完整堆栈跟踪:
2020-05-17 01:00:57.244 14576-14628/com.mycompany.mapboxpickerattempt I/oxpickerattemp: --------- beginning of crash
2020-05-17 01:00:57.265 14576-14628/com.mycompany.mapboxpickerattempt A/libc: /usr/local/google/buildbot/src/android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type jni::PendingJavaException" failed
2020-05-17 01:00:57.265 14576-14628/com.mycompany.mapboxpickerattempt A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14628 (OnlineFileSourc), pid 14576 (oxpickerattempt)
看来您基本上已经复制粘贴了这个示例,它应该可以工作:https://docs.mapbox.com/android/plugins/examples/place-picker/
能否请您分享应用程序级别 build.gradle 和项目级别 build.gradle,以及您的 activity_place_selection.xml?
能否将项目级别 build.gradle 更改为 link mapbox:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
这似乎需要 Java 8 声明。请将以下行添加到您的 build.gradle(应用程序级别):
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
这是我的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.placepicker"
minSdkVersion 24
targetSdkVersion 29
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 fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.12.0'
}