CodenameOne - Android app fails to start when building with android.buildToolsVersion=27

只谈情不闲聊 提交于 2019-12-08 03:49:07

问题


I'm using gcm and the app failed to start due to this error:

AndroidRuntime: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/net.segoia.opengroups.mobile-1/base.apk:classes2.dex)

This was caused by this line:

InstanceID instanceID = InstanceID.getInstance(this);

The problem is that when building for api level 27, support for android v4 is dropped.


回答1:


What solved the problem is adding these two build hints:

android.supportV4=true
android.supportv4Dep=compile 'com.android.support:support-v4:23.+'

This took a while to figure out, especially because the android.supportV4Dep is not even documented, and the android.supportV4 alone is not enough. I have learned about the android.supportV4Dep from another stackoverflow answer to a different question, so I thought I would document this here.



来源:https://stackoverflow.com/questions/52181747/codenameone-android-app-fails-to-start-when-building-with-android-buildtoolsve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!