美文网首页我爱编程
AndroidStudio使用Import Module常见BU

AndroidStudio使用Import Module常见BU

作者: 春夏见得月东生 | 来源:发表于2018-04-13 18:34 被阅读0次

    今天在项目中要实现城市三级联动的效果,本来使用SQlite已经实现,但是为了与ios端同步(想不明白为啥不是ios同步Android端);
    ios端的大兄弟发过来了一个.plist文件,说本质是个XML文件,我竟然觉得他说的好有道理。
    闲话少说,直接上菜。
    遇到的BUG

    1、这个bug出现的有点猝不及防

    Android SDK location should not contain whitespace,as this can cause problems with the NDK tools;
    

    这个错误导致在将Import Module过来的包无法引用到主项目中.
    出现这个bug的主要原因是sdk的导入路径出现了空格,关键在运行之前代码的时候没有任何问题,这就尴尬了,把空格去掉就可以。
    2、

    Error:Execution failed for task ‘:app:processDebugManifest’. 
    Manifest merger failed with multiple errors, see logss
    

    主要的是导入项目的build.gradle文件中的 compileSdkVersion和buildToolsVersion不一致或者不相符

    导入的项目中(例):

        compileSdkVersion 4
        buildToolsVersion "19.1.0"
    

    主项目中(例):

       compileSdkVersion 25
        buildToolsVersion '25.0.2'
    

    修改与主项目一致就OK
    3、

    Error:Dependency MyApplication:androidplistparserapp:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: 
    

    出现此类错误主要是build.gradle的配置出现错误,在导入的项目中build.gradle文件内----->如下图:


    image.png

    将划红线的 apply plugin:'com.android.application'--------->改成apply plugin: 'com.android.library';
    将applicationId "com.longevitysoft.android.xml.plist"删掉;

    apply plugin: 'com.android.library'
    android {
        compileSdkVersion 25
        buildToolsVersion '25.0.2'
    
        defaultConfig {
            minSdkVersion 17
            targetSdkVersion 25
            testApplicationId "com.longevitysoft.android.xml.plist.test"
            testInstrumentationRunner "com.longevitysoft.android.test.plist.InstrumentationTestRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    

    4、

    Error:Execution failed for task ':app:processDebugManifest'.
    > Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:7:9-43
        is also present at [MyApplication:androidplistparserapp:unspecified] AndroidManifest.xml:12:9-38 value=(@drawable/icon).
        Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:5:5-18:19 to override.
    

    上述错误,此类信息主要是导入的项目与主项目中的清单文件(AndroidManifest.xml)相冲突,将导入导入项目的AndroidManifest.xml文件中出土部分修改。
    修改前:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.longevitysoft.android.xml.plist"
          android:versionCode="1"
          android:versionName="1.0">
        <application android:icon="@drawable/icon" android:label="@string/app_name" />
        <uses-sdk android:minSdkVersion="4" />
    
    </manifest> 
    

    修改后:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.longevitysoft.android.xml.plist">
    
        <application
            android:allowBackup="true"
            android:supportsRtl="true">
    
        </application>
    
    </manifest> 
    

    相关文章

      网友评论

        本文标题:AndroidStudio使用Import Module常见BU

        本文链接:https://www.haomeiwen.com/subject/hathkftx.html