gpt4 book ai didi

java - 在 android studio 中的每个新项目中获取 [不幸的是应用程序停止工作],但不是

转载 作者:行者123 更新时间:2023-12-01 09:27:30 35 4
gpt4 key购买 nike

大家好,我是 java 和 android studio 的新手。从 android studio 的第一天起,我在 android studio 中遇到了一个奇怪的错误,它不允许我在我的设备上运行应用程序。

每当我使用新的包名称制作一些应用程序时,它总是会出现此错误[不幸的是应用程序停止工作]。但这里有一个问题,我从我的 friend 那里得到了一个项目文件,并且该项目在我的设备上运行良好[我的代码也是如此]我的意思是,如果我只是复制我的 friend android 项目上的代码和其他内容[如果将我的 friend android 项目作为基本文件],它运行时不会出现任何错误。

现在我必须一次又一次地强制重用该项目(我的 friend 给我的)来编写我的所有代码并在我的设备上运行它们。我想知道为什么这个问题没有发生在我 friend 的项目中,而只发生在我的所有新项目中。

如果有人能帮助我,我将非常感激。由于这个奇怪的错误,我无法使用我选择的包名称来测试我的应用程序。

LOGCAT 在这里

09-28 14:29:50.011  22023-22023/com.lunarpole.hirob I/dalvikvm﹕ Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to resolve interface method 16192: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0002
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob I/dalvikvm﹕ Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to resolve interface method 16194: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0002
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob I/dalvikvm﹕ Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
09-28 14:29:50.011 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to resolve interface method 16198: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0002
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to resolve virtual method 453: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ VFY: unable to resolve virtual method 475: Landroid/content/res/TypedArray;.getType (I)I
09-28 14:29:50.016 22023-22023/com.lunarpole.hirob D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0008
09-28 14:29:50.031 22023-22023/com.lunarpole.hirob E/VdcInflateDelegate﹕ Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:541)
at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:478)
at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:441)
at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:736)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:359)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:189)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.lunarpole.hirob.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
09-28 14:29:50.031 22023-22023/com.lunarpole.hirob D/AndroidRuntime﹕ Shutting down VM
09-28 14:29:50.031 22023-22023/com.lunarpole.hirob W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41fa3c08)
09-28 14:29:50.036 22023-22023/com.lunarpole.hirob E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.lunarpole.hirob, PID: 22023
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lunarpole.hirob/com.lunarpole.hirob.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f
at android.content.res.Resources.loadDrawable(Resources.java:3422)
at android.content.res.Resources.getDrawable(Resources.java:1909)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.lunarpole.hirob.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
            at android.app.ActivityThread.access$900(ActivityThread.java:175)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5602)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:986)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930)
at android.content.res.Resources.loadDrawable(Resources.java:3418)
            at android.content.res.Resources.getDrawable(Resources.java:1909)
            at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182)
            at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187)
            at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
            at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127)
            at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)
            at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)
            at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)
            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
            at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
            at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
            at com.lunarpole.hirob.MainActivity.onCreate(MainActivity.java:14)
            at android.app.Activity.performCreate(Activity.java:5451)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
            at android.app.ActivityThread.access$900(ActivityThread.java:175)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5602)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)

最佳答案

非常感谢所有在这个问题上帮助我的人。我通过替换依赖项解决了这个问题 来自

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
}

To
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

正确构建。我 friend 的 Gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.lunarpole.helloapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

错误的 Build.gradle 文件给了我错误

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.lunarpole.beauty"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
}

但是现在我想知道如何默认放置这些依赖项,以便每次我打开新项目和 roid studio 时都会自动将这些依赖项放入 gradle 中。如何做到这一点

关于java - 在 android studio 中的每个新项目中获取 [不幸的是应用程序停止工作],但不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39727658/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com