在Android Studio中导入项目后如何修复错误

时间:2019-01-17 08:53:32

标签: java android android-studio

我在Android Studio中有一个项目。重新安装操作系统后,我想将项目再次导入Android Studio,但出现此错误:

LogCat错误:

01-17 12:10:03.567 
13228-13228/com.nimaroid.introsliderproject 
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nimaroid.introsliderproject, PID: 13228
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nimaroid.introsliderproject/com.nimaroid.introsliderproject.IntroSliderActivity}: 
    java.lang.ClassNotFoundException: Didn't find class "com.nimaroid.introsliderproject.IntroSliderActivity" on path: 
    DexPathList[[zip file "/data/app/com.nimaroid.introsliderproject-1/base.apk", 
    zip file "/data/app/com.nimaroid.introsliderproject-1/split_lib_slice_9_apk.apk"],
    nativeLibraryDirectories=[/data/app/com.nimaroid.introsliderproject-1/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
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.nimaroid.introsliderproject.IntroSliderActivity" on path: 
    DexPathList[[zip file "/data/app/com.nimaroid.introsliderproject-1/base.apk", 
    zip file "/data/app/com.nimaroid.introsliderproject-

AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nimaroid.introsliderproject">
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"/>
    <activity android:name=".IntroSliderActivity"
        android:theme="@style/ads">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
</application>

1 个答案:

答案 0 :(得分:0)

我解决了我的问题,但也许对每个人都行不通。

在类似情况下,有时可以按照以下步骤更新Android Studio来解决该问题。

  1. 更新Android Studio;

  2. 打开项目;

  3. 更新Gradle(如果项目是在旧版本中构建的);

  4. compileSdkVersiontargetSdkVersion更新为最新版本;

  5. 将库更新为最新版本。

注意:以上步骤是手动操作,但默认情况下,Android Studio会为您提供执行这些步骤所需的消息。