0

我正在使用 Flutter,我在 Android Studio 中遇到了这个错误:

Error: Activity class {com.example.piedra_papel_tijera/com.HyenaGames.piedra_papel_tijera.MainActivity} does not exist

我到处更改公司名称,我不知道这个“例子”在哪里

但是,我有这个错误 en vs code:

java.lang.RuntimeException:无法实例化活动 ComponentInfo{com.HyenaGames.piedra_papel_tijera/com.HyenaGames.piedra_papel_tijera.MainActivity}:java.lang.ClassNotFoundException:在路径上找不到类“com.HyenaGames.piedra_papel_tijera.MainActivity”: DexPathList[[zip 文件“/data/app/com.HyenaGames.piedra_papel_tijera-9nyZCSZcFf3-hy2Byci2xQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.HyenaGames.piedra_papel_tijera-9nyZCSZcFf3-hy2Byci2xQ==/lib /arm64, /data/app/com.HyenaGames.piedra_papel_tijera-9nyZCSZcFf3-hy2Byci2xQ==/base.apk!/lib/arm64-v8a, /system/lib64]]

这是我的 Android 清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.HyenaGames.piedra_papel_tijera">
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="Piedra Papel Tijera y más..."
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

主要活动.kt:

package com.HyenaGames.piedra_papel_tijera

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

构建.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.HyenaGames.piedra_papel_tijera"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

我尝试了我在互联网上阅读的所有内容,但它对我不起作用,我错过了什么?

4

0 回答 0