代码之家  ›  专栏  ›  技术社区  ›  Tara

如何将OpenCameraApp作为一个模块集成到我的项目中

  •  0
  • Tara  · 技术社区  · 7 年前

    This 项目作为我的应用程序中的一个模块。当我积分时,得到如下所述的误差。我有这么多的链接,所以建议我降级工作室版本,或升级等 this for adding module in my project

    com.android.ide.common.process.ProcessException: Error while executing 
    'E:\Softwares\sdk1\build-tools\25.0.3\llvm-rs-cc.exe' with arguments {-O 3 -
     I E:\Softwares\sdk1\build-tools\25.0.3\renderscript\include\ -I 
    E:\Softwares\sdk1\build-tools\25.0.3\renderscript\clang-include\ -p D:\SVN-
    WORKS\MyApplication\openCamera\build\generated\source\rs\release -o D:\SVN-
    WORKS\MyApplication\openCamera\build\generated\res\rs\release\raw -target-
    api 15 D:\SVN-WORKS\MyApplication\openCamera\src\main\rs\align_mtb.rs 
    D:\SVN-WORKS\MyApplication\openCamera\src\main\rs\create_mtb.rs D:\SVN-
    WORKS\MyApplication\openCamera\src\main\rs\histogram_adjust.rs D:\SVN-
    WORKS\MyApplication\openCamera\src\main\rs\histogram_compute.rs D:\SVN-
    WORKS\MyApplication\openCamera\src\main\rs\process_hdr.rs}
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Tara    7 年前

    以下是在另一个应用程序中添加项目作为模块/库时可能遇到的困难的答案。

    跟随 this video tutorial

    以下是您需要考虑的几点。

    1. 更改构建的第一行。gradle(库)从“应用插件:com.android.application”到“应用插件:com.android.library”
    2. 从生成中删除applicationId。gradle(图书馆)
    3. 确保构建。gradle(应用程序)和build。gradle(库)应该完全相同。 如下所示

    建筑gradle(应用程序)

        apply plugin: 'com.android.application'
    
        android {
          compileSdkVersion 22
          buildToolsVersion "22.0.1"
    
          defaultConfig {
             applicationId "com.xyz.xyzxyz"
             minSdkVersion 7
             targetSdkVersion 22
             versionCode 1
             versionName "1.0"
         }
        buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        }
        }
    
         dependencies {
             compile project(':openCamera')
             compile fileTree(dir: 'libs', include: ['*.jar'])
         }
    

    建筑gradle(图书馆)

    apply plugin: 'com.android.library'
    
     android {
         compileSdkVersion 22
         buildToolsVersion "22.0.1"
    
         defaultConfig {
             minSdkVersion 7
             targetSdkVersion 22
             versionCode 1
             versionName "1.0"
         }
         buildTypes {
             release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
     dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.mcxiaoke.volley:library:1.0.18'
        compile 'com.android.support:appcompat-v7:22.0.0'
     }
    
    1. 如果应用程序和库模块都具有MainActivity和activity_main。xml文件,然后在应用程序或库中进行更改。因为您可能会得到rumTime错误,如#40(行号)处的二进制xml错误等。
    2. 您的android studio版本和项目级gradle依赖项应该具有相同的版本。比如,如果你的studio版本是2.3.1,那么Dependency块应该有“classpath”com.android.tools.build:gradle:2.3.1”
    3. 最后,从库的清单文件中删除库的mainActivity的标记。代码如下所示。如果你不删除或评论它,那么两个启动器将出现在你的项目中,它将创建两个图标。

          <!-- Comment or delete tag to avoid two launchers in your application -->
          <intent-filter> 
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
              <category android:name="android.intent.category.DEFAULT"/>
          </intent-filter>