diff --git a/app/build.gradle b/app/build.gradle index 03242f5..b5f06d1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,9 @@ -apply plugin: 'com.android.application' +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +// id 'kotlin-kapt' +} + def appName() { return "Mir4Updater" @@ -9,38 +14,40 @@ def releaseTime() { } android { - compileSdkVersion 30 -// buildToolsVersion "34.0.0" + namespace "com.example.mir4updater" + + compileSdkVersion 36 + buildToolsVersion "36.0.0" defaultConfig { applicationId "com.example.mir4updater" minSdkVersion 24 - targetSdkVersion 30 + targetSdkVersion 36 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true + ndk { //可以根据需要来自行选择并添加对应cpu类型的.so库。 abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // 还可以添加 'armeabi', 'x86', 'x86_64', 'mips', 'mips64' } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + } - vectorDrawables.useSupportLibrary = true + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } - viewBinding { - enabled = true - } - dataBinding { - enabled true - } + buildFeatures { + dataBinding true + buildConfig true + aidl true } // splits { @@ -84,40 +91,25 @@ android { debug { versionNameSuffix "_debug" minifyEnabled false - //Zipalign优化 - zipAlignEnabled true signingConfig signingConfigs.own - applicationVariants.all { variant -> - variant.outputs.each { output -> - if (outputFile != null) { - def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType.name}.apk" - output.outputFileName = fileName - } - } - } } release { - //混淆 minifyEnabled false - //Zipalign优化 - zipAlignEnabled true - //前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件 - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - //签名 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.own -// 将release版本的包名重命名,加上版本及日期 - applicationVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = "" - if (outputFile != null) { - def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType.name}.apk" - output.outputFileName = new File(outputFile, fileName) - } - } + } + } + + android.applicationVariants.all { variant -> + variant.outputs.all { output -> // 改为 all + def buildType = variant.buildType.name + if (buildType.contains("debug")) { + outputFileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk" + } else { + outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk" } } - } } @@ -126,6 +118,14 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(path: ':ttutils') + // 添加 Kotlin 标准库 + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + // 添加这行,使用 BOM 统一 Kotlin 相关库的版本 + implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version")) + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx3:1.11.0' + implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation "androidx.recyclerview:recyclerview:1.2.1" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7b925f0..3efe1b1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,14 +31,16 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + - + diff --git a/build.gradle b/build.gradle index 60445a7..7b4ed46 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,23 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - + ext.kotlin_version = '2.4.0' + repositories { google() mavenCentral() - maven { url "https://jitpack.io" } + maven { url 'https://jitpack.io' } + maven { url 'https://maven.google.com' } maven { url 'https://developer.huawei.com/repo/' } maven { url 'https://developer.hihonor.com/repo' } maven { url 'https://maven.aliyun.com/repository/central' } - maven { url "https://maven.aliyun.com/repository/jcenter" } + maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/google' } - } dependencies { - classpath 'com.android.tools.build:gradle:3.6.4' - + classpath 'com.android.tools.build:gradle:8.13.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -24,23 +25,27 @@ buildscript { } allprojects { - configurations.all { - resolutionStrategy { - force 'androidx.constraintlayout:constraintlayout:2.0.4' - force 'androidx.annotation:annotation:1.4.0' // 强制所有依赖使用 1.4.0 - } - } repositories { google() mavenCentral() - maven { url "https://jitpack.io" } + maven { url 'https://jitpack.io' } + maven { url 'https://maven.google.com' } maven { url 'https://developer.huawei.com/repo/' } maven { url 'https://developer.hihonor.com/repo' } maven { url 'https://maven.aliyun.com/repository/central' } - maven { url "https://maven.aliyun.com/repository/jcenter" } + maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/google' } - + } + + configurations.all { + resolutionStrategy.eachDependency { details -> + if (details.requested.group == 'org.jetbrains.kotlin') { + // 统一所有 Kotlin 标准库及扩展模块的版本,避免重复类冲突 + details.useVersion '1.8.10' + details.because '统一 Kotlin stdlib 版本以解决 duplicate class 冲突' + } + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a8d30a5..f904057 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip diff --git a/ttutils/CMakeLists.txt b/ttutils/CMakeLists.txt index e90653e..83cd0ae 100644 --- a/ttutils/CMakeLists.txt +++ b/ttutils/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.4.1) +project(ttutils) + # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. @@ -54,4 +56,6 @@ target_link_libraries( # Specifies the target library. # Links the target library to the log library # included in the NDK. - ${log-lib}) \ No newline at end of file + ${log-lib}) + +set_target_properties(ttutils PROPERTIES LINK_FLAGS "-Wl,-z,max-page-size=16384") \ No newline at end of file diff --git a/ttutils/build.gradle b/ttutils/build.gradle index d53d663..71bd654 100644 --- a/ttutils/build.gradle +++ b/ttutils/build.gradle @@ -1,6 +1,8 @@ apply plugin: 'com.android.library' android { + namespace "com.ttstd.ttutils" + compileSdkVersion 34 // buildToolsVersion "34.0.0" @@ -21,7 +23,7 @@ android { // build.gradle中移除armeabi mips等 //选择要添加的对应 cpu 类型的 .so 库。 - abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // 还可以添加 'armeabi', 'x86', 'x86_64', 'mips', 'mips64' } } diff --git a/ttutils/src/main/AndroidManifest.xml b/ttutils/src/main/AndroidManifest.xml index 58ccb7e..420288f 100644 --- a/ttutils/src/main/AndroidManifest.xml +++ b/ttutils/src/main/AndroidManifest.xml @@ -1,2 +1 @@ - +