のための私は、Android 4.3とAPI私Acitivty 18.
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_error.xml
from drawable resource ID #0x7f020098
at android.content.res.Resources.loadDrawable(Resources.java:2091)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.TextView.<init>(TextView.java:803)
at android.widget.EditText.<init>(EditText.java:60)
とサムスンのギャラクシーネクサスの電話でテストする場合にのみ、次のエラーに実行していますよ。 javaファイル、私は私のベクトル描画可能に設定するには、次の方法を使用して試してみた:
editTextNickname.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_error, 0);
editTextNickname.setCompoundDrawables(null, null,
ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_error), null);
以下に示すように、私は、私のbuild.gradleファイルの最新のサポートライブラリを使用しています:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.peprally.jeremy.peprally"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:support-vector-drawable:24.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.amazonaws:aws-android-sdk-ddb:2.+'
compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
StackOverflowに同様の問題が掲載されていますが、まだ解決策はありません。誰かが洞察力を持っているなら、助けてください!ありがとう!
< --edit - >
問題を無視し、それに戻ってきた後、私はVectorDrawableサポートされていない問題を回避するために固体解決策を見つけました。提案されたものの上に、あなたは以下のコードを使用してVectorDrawablesを作成することができます。
public static Drawable getAPICompatVectorDrawable(Context callingContext, int resource_id) {
if (android.os.Build.VERSION.SDK_INT >= 21) {
return ContextCompat.getDrawable(callingContext.getApplicationContext(), resource_id);
} else {
return VectorDrawableCompat.create(
callingContext.getResources(),
resource_id,
callingContext.getTheme());
}
}
私もXMLファイルに直接ベクトルドローアブルを入れしようとする問題がありました。そして私はそれを回避する方法を見つけることができませんでしたので、私は最終的にそれらを私のXMLファイルから取り出して、上記の関数と同じ関数を使用してプログラムでJavaに挿入しました。私のxmlの中にベクトルdrawableを使用して得たエラーは以下の通りです。もし誰かがより良い解決策を持っていれば、私はそれを聞いてみたいです!
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.
peprally.jeremy.peprally/com.peprally.jeremy.peprally.activities.
NewCommentActivity}:
android.view.InflateException: Binary XML file line #90: Error inflating class TextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #90:
Error inflating class TextView
omgはい、うまくいきました!詳しく教えてください!ヒントありがとう、私は解決のための日を探してきました! – jerbotron
さらに、私はFloatingActionButtonsのような他のUIコンポーネントとの互換性の問題に遭遇しています。 – jerbotron
私は誤解しているかもしれませんが、このGradleの設定は何か類似していませんか? 'vectorDrawables.useSupportLibrary = true' –