在主模块中找不到库模块中的软件包 [英] Packages from library module not found in main module

查看:95
本文介绍了在主模块中找不到库模块中的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,该项目是从Eclipse导入到Android Studio的.在Eclipse中,一切正常.

I got a project which I imported from Eclipse to Android Studio. In Eclipse everything worked well.

它包含一个主模块(Eclipse中的项目),该模块使用库模块(Eclipse中的库项目)中的软件包.由于迁移无法顺利进行,因此我手动创建了一个库模块,然后将所有源代码复制到了新创建的模块中.

It contains a main module (a project in Eclipse) which uses packages from a library module (library project in Eclipse). Since the migration did not went well, I have created a library module manually and just copied all the source code to the newly created module.

问题在于主模块似乎没有从库模块中找到软件包,而当我重建项目时,出现诸如软件包bla bla不存在"之类的错误.

The problem is that the main module doesn't seem to find the packages from the library module and when I rebuild the project I get errors like "package bla bla does not exist".

这是gradle.build的主要模块:

Here is the main module 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是库模块.

linphoneclean is the library module.

整个项目的设置.gradle:

The entire project's settings.gradle:

include ':linphoneclean'
include ':tigris'

这是库模块的build.gradle:

This is the build.gradle of the library module:

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(并且内部所有Java文件的减速度为package com.pointer.linphone,但是我仍然收到错误消息,说>包com.pointer.linphone不存在).

The structure of the library module includes for example folder: src/main/com/pointer/linphone (and inside there are all the java files with a deceleration of package com.pointer.linphone, Yet I still get an error saying >"package com.pointer.linphone does not exist).

我在做什么错了?

推荐答案

在同一个问题上解决了几个小时之后,这才对我有用.

After fighting with the same issue for hours here is what worked for me.

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

I've created a fresh project with blank activity, added a library module with a dummy class, defined the dependency. Verified that it works by importing the dummy class in the app. Then I copied all my relevant code from the real project.

我的想法是,这可能与IDE的iml文件有关,因为从头开始并在工作中进行了复制.

My thinking is that it was probably issue with IDE's iml files, since starting from scratch and copying stuff over worked.

这篇关于在主模块中找不到库模块中的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆