[INSTALL_FAILED_OLDER_SDK]Android-L失败

时间:2021-04-10 17:03:03

I'm trying to use the new CardView from Android L. I updated everything in the SDK manager, but I keep getting the following error:

我正在尝试使用Android l的新CardView,我在SDK管理器中更新了所有东西,但是我一直得到以下错误:

Failure [INSTALL_FAILED_OLDER_SDK]

失败(INSTALL_FAILED_OLDER_SDK)

This is my build.gradle file:

这是我的建立。gradle文件:

apply plugin: 'android'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId "www.thomascbeerten.com.nieuwetests"
        minSdkVersion 8
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    // Support Libraries
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:gridlayout-v7:19.1.0'
    compile 'com.android.support:mediarouter-v7:19.1.0'
    // compile 'com.android.support:support-v13:19.1.0'
    compile 'com.android.support:recyclerview-v7:+'
}

5 个解决方案

#1


54  

Recently there was a post here regarding the L SDK's incompatibility with prior versions of Android. I've been digging in AOSP repositories for quite a few hours now, and determined that the tools behave this way because they are designed to treat preview platforms differently. If you compile against a preview SDK (android-L), the build tools will lock minSdkVersion and targetSdkVersion to that same API level. This results in the produced application being unable to be installed on devices running older releases of Android, even if your application isn't doing anything specific to L. To make matters worse, the new support libs (CardView, RecyclerView, Palette, etc.) are also locked into the L API level, even though--according to their repository names--they should work on API level 7 just fine (and they do!).

最近在这里有一个关于L SDK与之前版本的Android不兼容的帖子。我已经在AOSP存储库中挖掘了好几个小时,并确定这些工具的行为是这样的,因为它们的设计目的是不同地对待预览平台。如果您使用preview SDK (android-L)编译,那么构建工具将把minSdkVersion和targetSdkVersion锁定到相同的API级别。这导致产生应用程序无法被安装在设备运行旧版本的Android,即使应用程序并不做任何特定于L。更糟的是,所新的支持库(CardView RecyclerView,面板等)也锁在API级别,即使——根据他们的存储库的名字——他们应该工作在API级别7日很好(他们做的!)。

See my Reddit post about this here, with a workaround.

看看我的Reddit网站关于这个的帖子,有一个变通的方法。

#2


5  

Once you have the above issues resolved as mentioned by Eddie. You might also run into another error;;

一旦你有了上述问题,正如艾迪所说。您可能还会遇到另一个错误;

Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

This will be present in your styles.xml . The quick fix is to replace it with the following below:

这将体现在你的风格中。xml。权宜之计是将其替换为以下内容:

<?xml version="1.0" encoding="utf-8"?>
 <resources>
<!--<style name="AppTheme" parent="android:Theme.Material.Light">-->
<style name="AppTheme" parent="android:Theme.Holo.Light">
</style>

#3


2  

Change

改变

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'

to

android {
  compileSdkVersion 21
  buildToolsVersion '21.0.2'

Note android-L is in single quotes but 21 isn't. 21 is an integer and not a string.

注意,android-L在单引号中,但21不是。21是整数而不是字符串。

#4


0  

When you compile with L it actually makes a change during compilation setting your minsdkversion to L. If you want to use RecyclerView or CardView I would recommend checking out RecyclerViewLib. RecyclerView and CardView have been moving into this library so that there is no min version L problem. The author also explained in his blog post how all L related code was removed to make it safe to use.

当您使用L编译时,它实际上在编译时将您的minsdkversion设置为L。如果您想使用可循环查看或CardView,我建议您检查回收利用。可回收的视图和CardView已经进入这个库,所以没有最小的版本L问题。作者还在他的博客文章中解释了如何删除所有L相关代码以使其安全使用。

To add RecyclerViewLb to your project just add the following line to your dependencies in your build.gradle file:

为您的项目添加可回收的视图,只需在您的构建中添加以下代码。gradle文件:

compile 'com.twotoasters.RecyclerViewLib:library:1.0.+@aar'

You then do not want to add the compile 'com.android.support:recyclerview-v7:+' to your build.gradle as you will get that through RecyclerViewLib.

然后,您不希望添加编译“com.android”。支持:recyclerview-v7:+您的构建。你可以通过回收利用来得到它。

#5


0  

I just ran into this problem. This can happen when your min sdk version and built targets are set to a higher API level/OS version than your phone is running. If you're using Android Studio, go to File > Project Structure > and edit relavent settings then Run again.

我只是碰到了这个问题。当您的最小sdk版本和构建目标被设置为比您的手机运行的更高的API级别/OS版本时,就会发生这种情况。如果你使用的是Android Studio,那就去>项目结构>和编辑relavent设置,然后再运行。

#1


54  

Recently there was a post here regarding the L SDK's incompatibility with prior versions of Android. I've been digging in AOSP repositories for quite a few hours now, and determined that the tools behave this way because they are designed to treat preview platforms differently. If you compile against a preview SDK (android-L), the build tools will lock minSdkVersion and targetSdkVersion to that same API level. This results in the produced application being unable to be installed on devices running older releases of Android, even if your application isn't doing anything specific to L. To make matters worse, the new support libs (CardView, RecyclerView, Palette, etc.) are also locked into the L API level, even though--according to their repository names--they should work on API level 7 just fine (and they do!).

最近在这里有一个关于L SDK与之前版本的Android不兼容的帖子。我已经在AOSP存储库中挖掘了好几个小时,并确定这些工具的行为是这样的,因为它们的设计目的是不同地对待预览平台。如果您使用preview SDK (android-L)编译,那么构建工具将把minSdkVersion和targetSdkVersion锁定到相同的API级别。这导致产生应用程序无法被安装在设备运行旧版本的Android,即使应用程序并不做任何特定于L。更糟的是,所新的支持库(CardView RecyclerView,面板等)也锁在API级别,即使——根据他们的存储库的名字——他们应该工作在API级别7日很好(他们做的!)。

See my Reddit post about this here, with a workaround.

看看我的Reddit网站关于这个的帖子,有一个变通的方法。

#2


5  

Once you have the above issues resolved as mentioned by Eddie. You might also run into another error;;

一旦你有了上述问题,正如艾迪所说。您可能还会遇到另一个错误;

Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

This will be present in your styles.xml . The quick fix is to replace it with the following below:

这将体现在你的风格中。xml。权宜之计是将其替换为以下内容:

<?xml version="1.0" encoding="utf-8"?>
 <resources>
<!--<style name="AppTheme" parent="android:Theme.Material.Light">-->
<style name="AppTheme" parent="android:Theme.Holo.Light">
</style>

#3


2  

Change

改变

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'

to

android {
  compileSdkVersion 21
  buildToolsVersion '21.0.2'

Note android-L is in single quotes but 21 isn't. 21 is an integer and not a string.

注意,android-L在单引号中,但21不是。21是整数而不是字符串。

#4


0  

When you compile with L it actually makes a change during compilation setting your minsdkversion to L. If you want to use RecyclerView or CardView I would recommend checking out RecyclerViewLib. RecyclerView and CardView have been moving into this library so that there is no min version L problem. The author also explained in his blog post how all L related code was removed to make it safe to use.

当您使用L编译时,它实际上在编译时将您的minsdkversion设置为L。如果您想使用可循环查看或CardView,我建议您检查回收利用。可回收的视图和CardView已经进入这个库,所以没有最小的版本L问题。作者还在他的博客文章中解释了如何删除所有L相关代码以使其安全使用。

To add RecyclerViewLb to your project just add the following line to your dependencies in your build.gradle file:

为您的项目添加可回收的视图,只需在您的构建中添加以下代码。gradle文件:

compile 'com.twotoasters.RecyclerViewLib:library:1.0.+@aar'

You then do not want to add the compile 'com.android.support:recyclerview-v7:+' to your build.gradle as you will get that through RecyclerViewLib.

然后,您不希望添加编译“com.android”。支持:recyclerview-v7:+您的构建。你可以通过回收利用来得到它。

#5


0  

I just ran into this problem. This can happen when your min sdk version and built targets are set to a higher API level/OS version than your phone is running. If you're using Android Studio, go to File > Project Structure > and edit relavent settings then Run again.

我只是碰到了这个问题。当您的最小sdk版本和构建目标被设置为比您的手机运行的更高的API级别/OS版本时,就会发生这种情况。如果你使用的是Android Studio,那就去>项目结构>和编辑relavent设置,然后再运行。