mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Android 5.2.0 SDK crash using android gradle build plugin 3.0.1 on Device under Android 4.4

Open cmxyzx opened this issue 9 years ago • 6 comments

Platform: Android Mapbox SDK version: 5.2.0

Steps to trigger behavior

  1. Using android gradle build plugin 3.0.1 complie project
  2. On Device runing Android 4.4 and under
  3. Crash caused by java.lang.VerifyError: com/mapbox/mapboxsdk/maps/widgets/MyLocationView

Expected behavior

Not crach

Actual behavior

Crash when load map

01-04 00:42:21.460 7721-7721/? I/dalvikvm: Failed resolving Lcom/mapbox/mapboxsdk/location/LocationSource; interface 6744 'Lcom/mapzen/android/lost/api/LocationListener;'
01-04 00:42:21.460 7721-7721/? W/dalvikvm: Link of class 'Lcom/mapbox/mapboxsdk/location/LocationSource;' failed
01-04 00:42:21.460 7721-7721/? W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/mapbox/mapboxsdk/location/LocationSource;)
 01-04 00:42:21.460 7721-7721/? W/dalvikvm: VFY: storing type 'Ljava/lang/Object;' into field type 'Lcom/mapbox/services/android/telemetry/location/LocationEngine;' (Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;.locationEngine)
 01-04 00:42:21.460 7721-7721/? W/dalvikvm: VFY:  rejecting opcode 0x5b at 0x0000
 01-04 00:42:21.460 7721-7721/? W/dalvikvm: VFY:  rejected Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;.init (Lcom/mapbox/mapboxsdk/location/LocationSource;)V
 01-04 00:42:21.460 7721-7721/? W/dalvikvm: Verifier rejected class Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;
 01-04 00:42:21.460 7721-7721/? W/dalvikvm: Class init failed in Constructor.constructNative (Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;)
 01-04 00:42:21.500 7721-7721/? I/dalvikvm: Rejecting re-init on previously-failed class Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView; v=0x41633be8
 01-04 00:42:21.500 7721-7721/? W/dalvikvm: Class init failed in Constructor.constructNative (Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;)
 01-04 00:42:21.500 7721-7721/? D/AndroidRuntime: Shutting down VM
 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.moji.mjweather, PID: 7721
 java.lang.VerifyError: com/mapbox/mapboxsdk/maps/widgets/MyLocationView
     at java.lang.reflect.Constructor.constructNative(Native Method)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
     at com.mapbox.mapboxsdk.maps.MapView.initialise(MapView.java:125)
     at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:114)
     at com.mapbox.mapboxsdk.maps.SupportMapFragment.onCreateView(SupportMapFragment.java:66)
     at android.support.v4.app.Fragment.performCreateView(Fragment.java:2248)
     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1340)
     at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
     at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:2997)
     at android.support.v4.app.Fragment.performPause(Fragment.java:2429)
     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1398)
     at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
     at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:2997)
     at android.support.v4.app.FragmentController.dispatchPause(FragmentController.java:225)
     at android.support.v4.app.FragmentActivity.onPause(FragmentActivity.java:448)

I'm upload the demo APP to demonstrate the crash MapboxCrashDemo.zip

cmxyzx avatar Nov 22 '17 09:11 cmxyzx

@cmxyzx thank you for providing the sample project but both @Guardiola31337 and me couldn't get it to start:

Error while executing: am start -n "com.example.diduan.mapboxdemo/com.example.diduan.mapboxdemo.FullscreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.diduan.mapboxdemo/.FullscreenActivity }
Error type 3
Error: Activity class {com.example.diduan.mapboxdemo/com.example.diduan.mapboxdemo.FullscreenActivity} does not exist.

Error while Launching activity

tobrun avatar Nov 22 '17 14:11 tobrun

@tobrun Please check the updated sample code below:

MapboxDemo.zip

If you still can't get demo running, you can try to create you own demo project with the following steps:

  1. Create new project using Android Studio 3.0/3.0.1 with the default android gradle build plugin setting
  dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }

And using Gradle 4.1 to build the project

gradledistributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
  1. Add mapbox SDK deps to Application module
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0@aar'
  1. With demo Activity code
public class FullscreenActivity extends FragmentActivity {
    String ACCESS_TOKEN = "SET_TOKEN";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_fullscreen);

        Mapbox.getInstance(getApplicationContext(), ACCESS_TOKEN);

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        SupportMapFragment mapFragment = SupportMapFragment.newInstance();
        transaction.add(R.id.fullscreen_content, mapFragment);
        transaction.commitAllowingStateLoss();
        mapFragment.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(MapboxMap mapboxMap) {
                Toast.makeText(FullscreenActivity.this, "MapLoadSuccess!", Toast.LENGTH_LONG).show();
            }
        });
    }
}
  1. Running the project on device with Android 4.4 or below ( API <= 19 )will get crash
W/dalvikvm: VFY: unable to find class referenced in signature (Lcom/mapbox/mapboxsdk/location/LocationSource;)
W/dalvikvm: VFY: storing type 'Ljava/lang/Object;' into field type 'Lcom/mapbox/services/android/telemetry/location/LocationEngine;' (Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;.locationEngine)
W/dalvikvm: VFY:  rejecting opcode 0x5b at 0x0000
W/dalvikvm: VFY:  rejected Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;.init (Lcom/mapbox/mapboxsdk/location/LocationSource;)V
W/dalvikvm: Verifier rejected class Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;
W/dalvikvm: Class init failed in Constructor.constructNative (Lcom/mapbox/mapboxsdk/maps/widgets/MyLocationView;)
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418e5c50)

cmxyzx avatar Nov 23 '17 01:11 cmxyzx

@cmxyzx thank you for reporting that back to us!

I was able to pinpoint where the crash was coming from and it should be fixed via #10579. It'll be available in the upcoming release 5.2.1.

Thanks again!

Guardiola31337 avatar Nov 29 '17 07:11 Guardiola31337

Closing here as #10579 landed. @cmxyzx Feel free to open new tickets if you have any other questions 😉

Guardiola31337 avatar Nov 29 '17 07:11 Guardiola31337

@Guardiola31337 Do we have an ETA for the 5.2.1 patch? We wanna update to 5.2.0 with our next release but this along with the offline issues is keeping us from sending out with 5.2.0.

DejanRistic avatar Nov 30 '17 16:11 DejanRistic

hi @DejanRistic ! We are actively working on 5.2.1 and expect it to go out in the next few weeks. In the mean time, you can test out the latest fixes using the 5.3.0-SNAPSHOT build and keep giving us feedback!

lilykaiser avatar Dec 01 '17 16:12 lilykaiser