How to change target build on Android project?

后端 未结 13 560
傲寒
傲寒 2020-12-04 11:01

I currently have an Android project in Eclipse.

I created it with a target build of 1.5 (sdk 3).

Now I want to change it so that it has a minSdk of 3 and tar

相关标签:
13条回答
  • 2020-12-04 11:20

    Another way on the command line if you are using ant is to use the android.bat script (Windows) or android script (Mac). It's in $SDK_DIR/tools.

    If you say,

    android.bat update project --path .  --target "android-8"
    

    it will regenerate your build.xml, AndroidManifest.xml, etc.

    0 讨论(0)
  • 2020-12-04 11:21

    Well I agree with Ryan Conrad on how to do it in eclipse, have you ensured you have changed your manifest.xml?

     <uses-sdk android:minSdkVersion="3" />
     <uses-sdk android:targetSdkVersion="8" />
    
    0 讨论(0)
  • 2020-12-04 11:22

    I had this problem too. What worked for me was to first un-check the previously selected SDK version before checking the new desired version. Then click okay.

    0 讨论(0)
  • 2020-12-04 11:27

    As Mike way says. Change target BEFORE doing anything in your project that requires a higher target like android:installLocation="auto".

    0 讨论(0)
  • 2020-12-04 11:28

    The problem sometimes occurs when there are errors in the project.

    For instance, if your project is configured with a target of 3.2 but the 3.2 libraries are not available, you will not be able to change the version to 4.0!

    The usual (perhaps brutal) solution I use is to create a new project with the correct target and copy src, res and manifest into the new project.

    Update:

    This seems to work:

    1. Change the selected through the build properties as normal
    2. Manually edit project.properties AND default.properties to make sure they both reflect the desired target.
    3. Close the project and re-open it

    I always run Android Tools | Fix Project Properties after making any changes to the build target.

    0 讨论(0)
  • 2020-12-04 11:29

    as per 2018, the targetSdkVersion can be set up in your app/build.gradle the following way:

    android {
        compileSdkVersion 26
        buildToolsVersion '27.0.3'
    
        defaultConfig {
           ...
           targetSdkVersion 26
        }
        ...
    }
    

    if you choose 26 as SDK target, be sure to follow https://developer.android.com/about/versions/oreo/android-8.0-migration

    0 讨论(0)
提交回复
热议问题