Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在主模块中找不到库模块的包大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个项目,我从 Eclipse导入到 Android studio.在Eclipse中一切都运行良好.

它包含一个主模块(Eclipse中的一个项目),它使用来自库模块的包(Eclipse中的库项目).由于迁移不顺利,我手动创建了一个库模块,只是将所有源代码复制到新创建的模块中.

问题是主模块似乎没有从库模块中找到包,当我重建项目时,我得到的错误就像“包bla bla不存在”.

这是gradle.build的主要模块:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "com.pointer.mamagoose"
        minSdkVersion 9
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':linphoneclean')
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile files('libs/firebase-client-android-2.5.0.jar')
    compile files('libs/apache-httpcomponents-httpclient.jar')
    compile files('libs/apache-httpcomponents-httpcore.jar')
    compile files('libs/android-support-v7-recyclerview.jar')
}

linphoneclean是库模块.

整个项目的setTings.gradle:

include ':linphoneclean'
include ':tigris'

这是库模块的build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testinstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs',include: ['*.jar'])
    androidTESTCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
        exclude group: 'com.android.support',module: 'support-Annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    TESTCompile 'junit:junit:4.12'
    compile 'com.google.code.gson:gson:2.6.2'
    compile files('libs/commons-lang3-3.4.jar')
    compile files('libs/linphone.jar')
    compile files('libs/firebase-client-android-2.5.0.jar')
}

库模块的结构包括例如文件夹:
src / main / com / pointer / linphone(里面有所有带有com.pointer.linphone包减速的java文件,但我仍然收到错误说>“包com.pointer.linphone不存在).

我究竟做错了什么?

解决方法

经过几个小时同样的问题,这对我有用.

我创建了一个包含空白活动的新项目,添加一个带有虚拟类的库模块,定义了依赖项.通过在应用程序中导入虚拟类来验证它是否有效.然后我从真实项目中复制了所有相关代码.

我的想法是它可能是IDE的iml文件的问题,因为从头开始并复制工作的东西.

大佬总结

以上是大佬教程为你收集整理的android – 在主模块中找不到库模块的包全部内容,希望文章能够帮你解决android – 在主模块中找不到库模块的包所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。