简体   繁体   English

应用程序在 Android Studio 上不断停止错误

[英]app keeps stopping error on Android Studio

I'm designed an application on Figma and I get the assets via using extension for Android Studio.我在 Figma 上设计了一个应用程序,我通过使用 Android Studio 的扩展来获取资产。 After that, I'm created a "no activity" from Android Studio , using API 33 .之后,我使用 API 33Android Studio创建了一个“无活动”。

Whatever, Figma plug-in that is "export kit" created a zip file.不管怎样,作为“导出工具包”的 Figma 插件创建了一个 zip 文件。 It contains a java folder, a res folder and "AndroidManifest.xml".它包含一个 java 文件夹、一个 res 文件夹和“AndroidManifest.xml”。 When I open the project and follow the "res > layout > login_page_activity.xml" it comes as layout to right side panel.当我打开项目并遵循“res > layout > login_page_activity.xml”时,它作为右侧面板的布局出现。 But when I run the application with emulator;但是当我用模拟器运行应用程序时; the application builded but after start process it suddenly stopped and there was a crash like "Weesi keeps stopping".应用程序已构建,但在启动过程后突然停止,并出现“Weesi 不断停止”之类的崩溃。 I can't get the view that I designed on figma.我无法获得我在 figma 上设计的视图。 Can anyone help?谁能帮忙? I'm sharing codes and screenshots.我正在分享代码和屏幕截图。

Figma design screenshot Figma设计截图

Figma设计截图;

Android Studio screenshot安卓工作室截图

在此处输入图像描述

The codes of "login_page_activity"; “login_page_activity”代码;


     
    /*
     *  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
    
    }
}
    

This usage generates error.这种用法会产生错误。 So I'm adding the following package;所以我要添加以下包;

import "com.example.weesi.R";

It solves.它解决了。 But in this sittuation the big problem is when I click the run on emulator, It gives error that is in the picture;但在这种情况下,最大的问题是当我点击在模拟器上运行时,它给出了图片中的错误;

在此处输入图像描述

This is logcat error.这是 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

AndroidManifest.xml AndroidManifest.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>

Please help me:(请帮我:(

I think you are not registering Activity in AndroidManifest.xml我认为您没有在AndroidManifest.xml中注册Activity

Please add your Activity in your AndroidManifest.xml请在您的AndroidManifest.xml中添加您的Activity

try this code,试试这段代码,

<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>

Update activity tag in your manifest.更新清单中的活动标签。

You should add your activities to the "AndroidManifest.xml" file.您应该将您的活动添加到“AndroidManifest.xml”文件中。 Add like this,像这样添加,

<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>

Then run app again.然后再次运行应用程序。 Then your problem will be solved!那么你的问题就迎刃而解了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM