0

我在 Android Studio 中有很大的问题。

运行项目需要很长时间。

它从来没有让我等待。

但几周前。我知道。

一件事是肯定的。

项目之一是问题。

我认为那是因为 gradle 在奇怪的项目中。

我需要帮助。

我浪费了太多时间。

这是我的应用程序 build.gradle

  plugins {
    id 'com.android.application'}

android {
    signingConfigs {
        debug {
            storeFile file('C:\\AndroidProject\\platform.jks')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.thirteenrain.jyndk"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "v1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.android.support:appcompat-v7:30.1.0'    //Permission Dialog
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation project(path: ':jyndklib')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
}

模块 build.gradle

plugins {
id 'com.android.library'
}

android {
    signingConfigs {
        debug {
            storeFile file('C:\\AndroidProject\\platform.jks')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    sourceSets {
        main {
            jni.srcDirs = []
            jniLibs.srcDirs 'libs'
        }
    }

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName 'v0.9.0'

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"

     //   externalNativeBuild {
      //      ndkBuild {
      //          arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "-j4"
      //      }
     //   }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    externalNativeBuild {
        ndkBuild {
            path file('src/main/jni/Android.mk')
        }
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


**project build.gradle**

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
      //  classpath 'com.novoda:bintray-release:'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
    tasks.withType(Javadoc) {
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle.properties

android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.enableJetifier=true
android.useDeprecatedNdk=true
android.enableBuildCache=true

项目结构

Android Gradle Plugin Version : 4.2.1
Gradle Version : 7.1

AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.thirteenrain.jyndk">

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <application
        android:launchMode="singleTask"
        android:allowBackup="true"
        android:icon="@mipmap/ic_factorytest"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_factorytest_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.JyNDK">
        <activity android:name=".PasswdActivity"
            android:screenOrientation="landscape" />
        <activity
            android:name="test.TestResult"
            android:windowSoftInputMode="stateAlwaysHidden" />
        <activity android:name="test.Test_usb"
            android:screenOrientation="landscape" />
        <activity android:name=".AllTestAcitivity"
            android:screenOrientation="landscape" />
        <activity android:name="test.Test_lan_client"
            android:screenOrientation="landscape" />
        <activity android:name="test.Test_lan_server"
            android:screenOrientation="landscape" />
        <activity
            android:name="test.Test_lan"
            android:screenOrientation="landscape"
            android:supportsRtl="true" />
        <activity android:name="test.Test_network"
            android:screenOrientation="landscape" />
        <activity android:name="test.Test_printer"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="stateAlwaysHidden" />
        <activity
            android:name="test.Test_serial"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="test.Test_lcd"
            android:screenOrientation="landscape"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity android:name=".MainActivity"
            android:screenOrientation="landscape"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".FirstMainActivity"
            android:screenOrientation="landscape" />
    </application>

</manifest>

另一个运行的项目很快。但只有这个项目运行为时已晚。

并且在运行应用程序后没有加载。只需单击运行“应用程序”shift+f10 请帮助我。

4

0 回答 0