gpt4 book ai didi

android - 无法实例化 Activity ...在路径 : DexPathList (with instant run) 上找不到类 WelcomeActivity

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:19:20 25 4
gpt4 key购买 nike

几天来,我一直在为我的项目苦苦挣扎,突然间,从一个构建/部署到另一个构建/部署,我开始遇到以下异常。没有任何更新或更改,我只是想在它发生时在不同的设备上运行该应用程序(就像其他任何一天一样)。

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.my.app.flavor.debug/com.my.app.ui.activity.WelcomeActivity}: java.lang.ClassNotFoundException: Didn't find class "com.my.app.flavor.ui.activity.WelcomeActivity" on path: DexPathList[[zip file "/data/app/com.my.app.flavor.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/**com.my.app.flavor.**debug-2/lib/x86, /data/app/com.my.app.flavor.debug-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.my.app.ui.activity.WelcomeActivity" on path: DexPathList[[zip file "/data/app/com.my.app.flavor.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.my.app.flavor.debug-2/lib/x86, /data/app/com.my.app.flavor.debug-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: com.my.app.ui.activity.WelcomeActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

调试 构建无法在我的所有 3 台设备(Android 5.0.2、6.0.1 和 7.0)和模拟器上部署/启动。Run 在我选择两个或多个部署目标时有效,但不是只有一个(因为即时运行在多个目标时被禁用)。调试运行 在禁用即时运行时工作

我的项目有多种风格和 applicationIds(如 Android wear project with 3 flavors, 3 buildTypes and 2 applicationIdSuffixes)。发生错误时,所有 gradle 文件均未更改, list 也未更改。

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
package="com.my.app">
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />

<!-- PROTECTION_NORMAL -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- PROTECTION_DANGEROUS -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- Protection unknown -->
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.hardware.location" android:required="true" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name="net.hockeyapp.android.UpdateActivity" />
<activity
android:name=".ui.activity.WelcomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.StartActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />

<activity
android:name="com.facebook.LoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.NotificationActivity"
android:screenOrientation="portrait" />

<activity
android:name=".ui.activity.OtherActivity"
android:label="@string/cards_register_card"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.OneMoreActivity"
android:label="@string/a_title"
android:parentActivityName=".ui.activity.OtherActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.activity.OtherActivity" />
</activity>

<service android:name=".service.WearableListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />

<data
android:host="*"
android:pathPrefix="/path"
android:scheme="wear" />
</intent-filter>
</service>

<!-- GCM START -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />

<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<service
android:name=".service.PushListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".service.PushInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name=".service.PushRegistrationIntentService"
android:exported="false"></service>
<!-- GCM END -->

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_api_key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />

<!-- Register AnalyticsReceiver and AnalyticsService to support background dispatching on non-Google Play devices -->
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>

<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false" />
</application>

到目前为止,我已经尝试了以下方法:

  • 干净,干净,干净,再干净
  • 删除所有/build文件夹
  • 重新启动 Android Studio (2.2)、我的电脑和所有设备
  • 在所有设备和模拟器上卸载我的所有应用
  • 尝试使用启动选项下指定的 Activity 创建新的运行配置(有时在单个部署目标上运行时有效,但在调试 模式)
  • 在停用即时运行的情况下运行,然后使用它运行激活
  • 重新安装 Android Studio

非常感谢任何帮助让它在即时运行中再次工作的帮助!

最佳答案

这似乎在启用即时运行时不时发生(尽管在 Android Studio 的后期更新中并不经常发生)。只需禁用即时运行,运行应用程序,再次启用即时运行。

希望 Instant Run 不断改进。

(对我来说,在分支之间切换似乎更频繁地触发这种情况。)

关于android - 无法实例化 Activity ...在路径 : DexPathList (with instant run) 上找不到类 WelcomeActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39704593/

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