AndroidStuio打開一個已存在的項目


開源項目:掃一掃

 

下載zxing-master通過AndroidStudio直接打開構建時提示Gradle問題,不了解Gradle怎么回事,更具提示dowload失敗了。

於是百度嘗試第二種方式,如下:

1.AndroidStudio本地先創建一個空項目OpenSource-scaner

2.根據OpenSource-scaner創建自動生成的Gradle配置文件修改zxing-master中對應的文件。

- app/build.gradle

compileSdkVersion、buildToolsVersion、minSdkVersion、targetSdkVersion

-gradle/wrapper/gradle-wrapper.properties

distributionUrl

-build.gradle

classpath

3.AndroidStudio->file->open打開zxing

4.等待Gradle同步

Gradle sync這時成功了。

5.(工具欄中的錘子)ctrl+F9構建一下

6.這時app/release路徑下有zxing.apk生成

安裝生成的apk到手機中,試了下識別出二維碼內容。

 

問題

1.安裝apk提示

Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl924957567.tmp/base.apk has no certificates at entry AndroidManifest.xml]
原因:打包的apk沒簽名,app-release-unsigned.apk。

解決:根據zxing-master build.gradle添加簽名,然后構建apk。

具體操作如下:

step1:AndroidStudio Build -> Generate Signed Bundle or APK -> APK,然后next。

step2:根據項目build.gradle添加簽名信息

  Key store path選擇項目自帶的zxing.jks。

  Key store password:123456

  Key alias:zxingyzq

  Key password:123456

step3:Build -> Make Project構建apk

這時在zxing-master\app\build\outputs\apk\debug會生成簽名apk:app-debug.apk

step4:adb install app-debug.apk安裝apk

 2.打開開源Gradle Sync時提示:NDK not configured

原因:這次是因為NDK版本不一致找不到NDK導致的。

解決:指定NDK路徑

step1:右上角,打開搜索窗口,輸入Project Structure ...

step2:選Project Structure窗口download Android NDK,選擇NDK的路徑,然后apply

step3:重新同步加載

3.導入提示:Your project path contains non-ASCII characters

原因:

解決:添加android.overridePathCheck=true到gradle.properties

 4.sync時

Cause: com.android.builder.sdk.LicenceNotAcceptedException: Failed to install the following Android SDK packages as some licences have not been accepted.
ndk;21.3.6528147 NDK (Side by side) 21.3.6528147
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: D:\Program Files\AndroidSDK
Failed to install the following Android SDK packages as some licences have not been accepted.
ndk;21.3.6528147 NDK (Side by side) 21.3.6528147
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: D:\Program Files\AndroidSDK

 解決:進入AndroidSDK\tools\bin,cmd執行:sdkmanager.bat --licenses ,一路y

5.

Location specified by ndk.dir (/Users/dp/Library/Android/sdk/ndk-bundle) did not contain a valid NDK and and couldn't be used

解決:注掉local.properties中n

dk.dir=/Users/dp/Library/Android/sdk/ndk-bundle

7.

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve project :openCVLibrary401.
Required by:
project :app
Caused by: org.gradle.internal.component.NoMatchingConfigurationSelectionException: Unable to find a matching configuration of project :openCVLibrary401:
- None of the consumable configurations have attributes.

 8.

ERROR: Library projects cannot set applicationId. applicationId is set to 'org.opencv' in default config.
Affected Modules: openCVLibrary401

原因:OpenCV-sdk導入時build.gradle配置中參數不正確

修改前:

defaultConfig {
applicationId "org.openCV"
}
應修改:
defaultConfig {
applicationId "org.openCVLibrary401"
}
這個和工程中導入依賴對應,

 

參考鏈接:

https://docs.gradle.org/current/userguide/compatibility.html#compatibility

https://docs.gradle.org/current/userguide/installation.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM