CodenameOne-使用android.buildToolsVersion = 27构建时,Android应用无法启动 [英] CodenameOne - Android app fails to start when building with android.buildToolsVersion=27
问题描述
我正在使用gcm,由于该错误,应用无法启动:
I'm using gcm and the app failed to start due to this error:
AndroidRuntime:java.lang.IllegalAccessError:方法
类'com.google.android.gms.iid.zzd'(
'com的声明)无法访问'void
android.support.v4.content.ContextCompat。()'。 google.android.gms.iid.zzd'出现在
/data/app/net.segoia.opengroups.mobile-1/base.apk:classes2.dex)
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)
这是由以下行引起的:
InstanceID instanceID = InstanceID.getInstance(this);
问题是,当构建api级别27时,对Android v4的支持会下降。
The problem is that when building for api level 27, support for android v4 is dropped.
推荐答案
解决问题的方法是添加以下两个构建提示:
What solved the problem is adding these two build hints:
android.supportV4=true
android.supportv4Dep=compile 'com.android.support:support-v4:23.+'
这花了一段时间才弄清楚,尤其是因为android.supportV4Dep甚至都没有记录,仅靠android.supportV4还是不够的。我已经从另一个stackoverflow答案的另一个问题中学到了android.supportV4Dep,所以我想我会在这里做记录。
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.
这篇关于CodenameOne-使用android.buildToolsVersion = 27构建时,Android应用无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!