2016-01-13 51 views
0

我已經在我的項目3個模塊:改用Android庫中的另一個Android模塊

Modules

在「IA」模塊我使用的負載C代碼NDK。

在'android'我有我的遊戲菜單。

在'核心'我有我的圖形界面(libgdx)。

我想在覈心中使用'ia'。

當我把「import eu.epitech.ia」我有一個錯誤:「找不到符號類ia」。

在從的build.gradle我添加依賴「編制項目(‘:IA’)。

我不知道該怎麼辦了使用我的IA類中的‘核心’模塊

。的android的build.gradle

apply plugin: "com.android.model.application" 

model { 
    android { 
     compileSdkVersion = 23 
     buildToolsVersion = "23.0.2" 
     defaultConfig.with { 
      applicationId = "eu.epitech.gomoku.android" 
      minSdkVersion.apiLevel = 4 
      targetSdkVersion.apiLevel = 23 
     } 
    } 

    android.buildTypes { 
     release { 
      minifyEnabled = false 
      proguardFiles.add(file("proguard-rules.pro")) 
     } 
    } 

    android.sources { 
     main { 
      manifest { 
       source { 
        srcDir "." 
        include "AndroidManifest.xml" 
       } 
      } 
      res { 
       source { 
        srcDir "res" 
       } 
      } 
      assets { 
       source { 
        srcDir "assets" 
       } 
      } 
      java { 
       source { 
        srcDir "src" 
       } 
      } 
      jniLibs { 
       source { 
        srcDir "libs" 
       } 
      } 
      jni { 
       source { 
        srcDir "jni" 
       } 
      } 
     } 
    } 

} 
// called every time gradle gets executed, takes the native dependencies of 
// the natives configuration, and extracts them to the proper libs/ folders 
// so they get packed with the APK. 
task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs(); 
    file("libs/armeabi-v7a/").mkdirs(); 
    file("libs/x86/").mkdirs(); 

    configurations.natives.files.each { jar -> 
     def outputDir = null 
     if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") 
     if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") 
     if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 
     if (outputDir != null) { 
      copy { 
       from zipTree(jar) 
       into outputDir 
       include "*.so" 
      } 
     } 
    } 
} 
task run(type: Exec) { 
    def path 
    def localProperties = project.file("../local.properties") 
    if (localProperties.exists()) { 
     Properties properties = new Properties() 
     localProperties.withInputStream { instr -> 
      properties.load(instr) 
     } 
     def sdkDir = properties.getProperty("sdk.dir") 
     if (sdkDir) { 
      path = sdkDir 
     } else { 
      path = "$System.env.ANDROID_HOME" 
     } 
    } else { 
     path = "$System.env.ANDROID_HOME" 
    } 

    def adb = path + "/platform-tools/adb" 
    commandLine "$adb", "shell", "am", "start", "-n", "eu.epitech.gomoku.android/eu.epitech.gomoku.android.AndroidLauncher" 
} 
// sets up the Android Eclipse project, using the old Ant based build. 
eclipse { 
    // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin 
    // ignores any nodes added in classpath.file.withXml 
    sourceSets { 
     main { 
      java.srcDirs "src", "gen" 
     } 
    } 

    jdt { 
     sourceCompatibility = 1.6 
     targetCompatibility = 1.6 
    } 

    classpath { 
     plusConfigurations += [project.configurations.compile] 
     containers "com.android.ide.eclipse.adt.ANDROID_FRAMEWORK", "com.android.ide.eclipse.adt.LIBRARIES" 
    } 

    project { 
     name = appName + "-android" 
     natures "com.android.ide.eclipse.adt.AndroidNature" 
     buildCommands.clear(); 
     buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder" 
     buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder" 
     buildCommand "org.eclipse.jdt.core.javabuilder" 
     buildCommand "com.android.ide.eclipse.adt.ApkBuilder" 
    } 
} 
// sets up the Android Idea project, using the old Ant based build. 
idea { 
    module { 
     sourceDirs += file("src"); 
     scopes = [COMPILE: [plus: [project.configurations.compile]]] 

     iml { 
      withXml { 
       def node = it.asNode() 
       def builder = NodeBuilder.newInstance(); 
       builder.current = node; 
       builder.component(name: "FacetManager") { 
        facet(type: "android", name: "Android") { 
         configuration { 
          option(name: "UPDATE_PROPERTY_FILES", value: "true") 
         } 
        } 
       } 
      } 
     } 
    } 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile "com.android.support:support-v4:23.+" 
    compile project(':ia') 
} 

//apply plugin: 'com.android.model.application' 
// 
//dependencies { 
// compile project(':ia') 
//} 

IA的build.gradle

apply plugin: "com.android.model.library" 

model { 
    android { 
     compileSdkVersion = 23 
     buildToolsVersion = "23.0.2" 
     defaultConfig.with { 
      minSdkVersion.apiLevel = 4 
      targetSdkVersion.apiLevel = 23 
     } 
    } 

    android.ndk { 
     moduleName = "hello-jni" 
    } 

    android.buildTypes { 
     release { 
      minifyEnabled = false 
      proguardFiles.add(file("proguard-rules.pro")) 
     } 
    } 

    android.productFlavors { 
     // for detailed abiFilter descriptions, refer to "Supported ABIs" @ 
     // https://developer.android.com/ndk/guides/abis.html#sa 
     create("arm") { 
      ndk.abiFilters.add("armeabi") 
     } 
     create("arm7") { 
      ndk.abiFilters.add("armeabi-v7a") 
     } 
     create("arm8") { 
      ndk.abiFilters.add("arm64-v8a") 
     } 
     create("x86") { 
      ndk.abiFilters.add("x86") 
     } 
     create("x86-64") { 
      ndk.abiFilters.add("x86_64") 
     } 
     create("mips") { 
      ndk.abiFilters.add("mips") 
     } 
     create("mips-64") { 
      ndk.abiFilters.add("mips64") 
     } 
     // To include all cpu architectures, leaves abiFilters empty 
     create("all") 
    } 

    android.sources { 
     main { 
      manifest { 
       source { 
        srcDir "." 
        include "AndroidManifest.xml" 
       } 
      } 
      res { 
       source { 
        srcDir "res" 
       } 
      } 
      assets { 
       source { 
        srcDir "assets" 
       } 
      } 
      java { 
       source { 
        srcDir "src" 
       } 
      } 
      jniLibs { 
       source { 
        srcDir "libs" 
       } 
      } 
      jni { 
       source { 
        srcDir "jni" 
       } 
      } 
     } 
    } 

} 

核心的build.gradle

apply plugin: "java" 
sourceCompatibility = 1.6 
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 
sourceSets.main.java.srcDirs = ["src/"] 
eclipse.project { 
    name = appName + "-core" 
} 
dependencies { 

} 

感謝

+0

你在settings.gradle文件中添加模塊? –

+0

什麼是'應用程序級gradle文件'? –

+0

對不起,我的意思是'settings.gradle'文件。 –

回答

-1

你有沒有嘗試添加到build.graddle此行compile project(':ia')

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:22.2.1' 

    compile project(':ia')} 
+0

再次閱讀問題! –

+0

我試着編譯fileTree(dir:'libs',include:['* .jar'])testcompile'junit:junit:4.12' compile「com.android.support:support-v4:23。 +「 編譯項目(':ia') }'但不工作 –

+0

好吧你有嘗試添加一個庫模塊的依賴嗎?更多信息:[在庫模塊中添加依賴項](http://developer.android.com/sdk/installing/create-project.html) –

相關問題