【问题标题】:Apk doesn't work after changing compileSdkVersion to android-P将 compileSdkVersion 更改为 android-P 后,Apk 不起作用
【发布时间】:2018-06-15 11:07:27
【问题描述】:

真的很奇怪,我创建了一个新的空项目,然后我将文件设置 compileSdkVersion 从 27.1 Oreo 更改为 android-P,然后我将应用程序重构为 AndroidX,如果我在模拟器上运行它或通过 adb connect with 运行它,它工作正常我的设备。但是当我尝试构建 apk 并将其安装在我的手机上时,会出现问题 - “未安装应用程序”。但在我更改 compileSdkVersion apk 之前安装正常。

清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ru.scapegoats.myapplicationmmmm">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".main"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        </application>

</manifest>

分级:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 'android-P'
    defaultConfig {
        applicationId "ru.scapegoats.myapplication"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
    implementation 'com.google.android.material:material:1.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
}

【问题讨论】:

  • 清理项目并构建apk
  • 您要安装哪个操作系统版本的 APK?
  • 4.4.2 kitkat 超过 minsdk
  • 清洁没有帮助
  • 可能是 AS 3.2 预览的问题?

标签: android


【解决方案1】:

您无法在旧操作系统上使用compileSdkVersion 'android-P' 预览版安装应用程序。

由于 Android P 的 beta 版本已经发布,请将 compileSdkVersion 更改为 28:

compileSdkVersion 28

注意:确保您有互联网连接,以便可以下载正确的 SDK 更新。

【讨论】:

  • 非常感谢,我真的很感激。
  • @Andrew 没问题。享受编码:-)
猜你喜欢
  • 2018-08-17
  • 2015-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多