在主模块中找不到库模块中的包

Yon*_*Nir 6 android module android-library android-studio

我有一个从 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')
}
Run Code Online (Sandbox Code Playgroud)

linphoneclean 是库模块。

整个项目的settings.gradle:

include ':linphoneclean'
include ':tigris'
Run Code Online (Sandbox Code Playgroud)

这是库模块的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')
}
Run Code Online (Sandbox Code Playgroud)

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

我究竟做错了什么?

小智 1

在与同一问题斗争了几个小时之后,这对我有用。

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

我的想法是,这可能是 IDE 的 IML 文件的问题,因为从头开始并复制内容很费劲。