Android Studio上的应用持续停止错误

8mmmxcuj  于 2022-12-21  发布在  Android
关注(0)|答案(3)|浏览(225)

我在Figma上设计了一个应用程序,并通过使用Android Studio的扩展获得了资产。之后,我使用API 33Android Studio创建了一个"无活动"。
无论如何,Figma插件是"导出工具包"创建了一个zip文件。它包含一个java文件夹,一个res文件夹和"AndroidManifest.xml"。当我打开项目并按照"res〉layout〉login_page_activity.xml",它作为布局出现在右侧面板。但当我用模拟器运行应用程序时;应用程序建立,但在启动过程后,它突然停止,并有一个崩溃像"Weesi保持停止"。我不能得到我在figma上设计的视图。有人能帮忙吗?我分享代码和截图。

    • Figma设计截图**

    • Android Studio 屏幕截图**

  • "登录页面活动"的代码;*
/*
     *  This content is generated from the API File Info.
     *  (Alt+Shift+Ctrl+I).
     *
     *  @desc       
     *  @file       login_page
     *  @date       Sunday 18th of December 2022 06:47:08 PM
     *  @title      Page 1
     *  @author     
     *  @keywords   
     *  @generator  Export Kit v1.3.figma
     *
     */
    

package exportkit.figma;

import android.app.Activity;
import android.os.Bundle;

import android.view.View;
import android.widget.ImageView;

public class login_page_activity extends Activity {

    
    private View _bg__login_page;
    private ImageView vector;
    private ImageView vector_ek1;
    private ImageView vector_ek2;
    private ImageView vector_ek3;
    private ImageView vector_ek4;
    private ImageView vector_ek5;
    private ImageView vector_ek6;
    private View rectangle_1;
    private ImageView mask_group;
    private ImageView vector_ek7;
    private ImageView mask_group_ek1;
    private ImageView vector_ek8;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_page);

        
        _bg__login_page = (View) findViewById(R.id._bg__login_page);
        vector = (ImageView) findViewById(R.id.vector);
        vector_ek1 = (ImageView) findViewById(R.id.vector_ek1);
        vector_ek2 = (ImageView) findViewById(R.id.vector_ek2);
        vector_ek3 = (ImageView) findViewById(R.id.vector_ek3);
        vector_ek4 = (ImageView) findViewById(R.id.vector_ek4);
        vector_ek5 = (ImageView) findViewById(R.id.vector_ek5);
        vector_ek6 = (ImageView) findViewById(R.id.vector_ek6);
        rectangle_1 = (View) findViewById(R.id.rectangle_1);
        mask_group = (ImageView) findViewById(R.id.mask_group);
        vector_ek7 = (ImageView) findViewById(R.id.vector_ek7);
        mask_group_ek1 = (ImageView) findViewById(R.id.mask_group_ek1);
        vector_ek8 = (ImageView) findViewById(R.id.vector_ek8);
    
        
        //custom code goes here
    
    }
}
    • 这种用法会产生错误,所以我添加了以下包;**
import "com.example.weesi.R";
    • 它解决。但在这种情况下的大问题是,当我点击运行模拟器,它给出的错误是在图片中;**

    • 这是logcat错误。**
--------- beginning of crash
2022-12-19 10:17:23.762 4426-4426/com.example.weesi E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.weesi, PID: 4426
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.weesi/com.example.weesi.login_page_activity}: java.lang.ClassNotFoundException: Didn't find class "com.example.weesi.login_page_activity" on path: DexPathList[[zip file "/data/app/~~ErUMd9SFlYIDuqrzhu5b3A==/com.example.weesi-SEYRsnvF0Xzn0PVo4BQkXg==/base.apk"],nativeLibraryDirectories=[/data/app/~~ErUMd9SFlYIDuqrzhu5b3A==/com.example.weesi-SEYRsnvF0Xzn0PVo4BQkXg==/lib/x86_64, /system/lib64, /system_ext/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3551)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7872)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.weesi.login_page_activity" on path: DexPathList[[zip file "/data/app/~~ErUMd9SFlYIDuqrzhu5b3A==/com.example.weesi-SEYRsnvF0Xzn0PVo4BQkXg==/base.apk"],nativeLibraryDirectories=[/data/app/~~ErUMd9SFlYIDuqrzhu5b3A==/com.example.weesi-SEYRsnvF0Xzn0PVo4BQkXg==/lib/x86_64, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1339)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3538)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.app.ActivityThread.main(ActivityThread.java:7872) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
2022-12-19 10:17:23.786 4426-4495/com.example.weesi D/libEGL: loaded /vendor/lib64/egl/libEGL_emulation.so
2022-12-19 10:17:23.791 4426-4495/com.example.weesi D/libEGL: loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
    • 安卓清单. xml**
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="exportkit.figma" >

    <application
        android:allowBackup="true"
        android:theme="@style/AppTheme"
        android:label="@string/app_name" >
        <activity
        android:name=".login_page_activity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:exported="true"  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>
    • 请帮助我:(**
vlju58qv

vlju58qv1#

试试这个代码,

<activity
    android:name="com.example.weesi.login_page_activity"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:label="@string/app_name"
    android:exported="true"  >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

更新清单中的活动标记。

frebpwbc

frebpwbc2#

我认为您没有在AndroidManifest.xml中注册Activity
请将您的Activity添加到您的AndroidManifest.xml

z9gpfhce

z9gpfhce3#

您应该将您的活动添加到“AndroidManifest.xml”文件中。

<activity
android:name="YOUR_ACTIVITY"
android:exported="true"  >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <meta-data
            android:name="android.app.lib_name"
            android:value="" />
</activity>

然后再次运行应用程序。然后您的问题将得到解决!

相关问题