android studio串号,AndroidStudio使用常见问题集锦
原標題:AndroidStudio使用常見問題集錦
配置AndroidStudio讓編譯更快
在個人.gradle文件夾下添加 gradle.properties 文件:
文件內容如下:
org.gradle.daemon=true
修改Android項目更目錄中的gradle.properties文件:
文件內容如下:
# Project-wide Gradle settings.# IDE (e.g. Android Studio) users:# Settings specified in this file will override any Gradle settings# configured through the IDE.# For more details on how to configure your build environment visit# http://www.gradle.org/docs/current/userguide/build_environment.html# The Gradle daemon aims to improve the startup and execution time of Gradle.# When settotrue the Gradle daemon isto run the build.# TODO: disable daemon on CI, since builds should be clean and reliable on serversorg.gradle.daemon=true# Specifies the JVM arguments used for the daemon process.# The setting is particularly useful for tweaking memorysettings.# Defaultvalue: -Xmx10248m -XX:MaxPermSize=256morg.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8# When configured, Gradle will run in incubating parallelmode.# This option should only be used with decoupled projects. More details, visit# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projectsorg.gradle.parallel=true# Enables new incubating mode that makes Gradle selective when configuring projects.# Only relevant projects are configured which results in faster builds forlarge multi-projects.# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demandorg.gradle.configureondemand=true
解決方法數超過65535問題
錯誤描述
一般情況下一款簡單的Android應用的方法數不會超過65535,但是隨著大量優秀的開源項目導入到項目中,方法數一般會超過這個數,這時如果你再編譯應用,則會報錯。
NoClassDefFoundError //某個方法找不到//錯誤情況大致如下Could not find class ‘xxxx’ , referenced frommethod ‘xxxxx’
解決辦法
(1)在app/build.gradle中添加:
dependencies { //multidex supportcompile'com.android.support:multidex:1.0.0'}
(2)讓自定義的類繼承自 MultiDexApplication,并修改onCreate()方法如下:
@OverridepublicvoidonCreate(){ //MultiDex 支持 65535 方法數量限制,注意,此方法要在super.onCreate()之前調用 MultiDex.install(getApplicationContext()); super.onCreate(); }
三方包的導入及build.gradle配置
android{ //添加.so庫依賴sourceSets { main { jniLibs.srcDirs = ['libs'] } }}// 為了讓編譯器能在libs 目錄下找到引用的 .aar 文件repositories { flatDir { dirs 'libs'//this way we can find the .aar file in libs folder }}dependencies { //引用遠程倉庫包compile'com.squareup.picasso:picasso:2.5.2'//引用app/libs 目錄下包compile files('libs/gson-2.2.4.jar') //引用項目庫文件 文件結構 /app /stickyListView ,注意配置 setting.gradle 文件 : include ':app',':stickyListView'compileproject(':stickyListView') //引入aar庫文件compile(name:'aar_library_name', ext:'aar') //改.aar文件位于app/libs目錄下,并且已經配置repositories}
Android常用命令
ADB相關命令
(1)獲取連接到的手機序列號
adb get-serialno
(2)查看當前連接的設備
adb devices
(3)重啟adb server
adb kill-serveradb start-server
秘鑰相關命令
(1)查看keystore的信息
keytool -list -v -keystore xp.jks或者:keytool -list -keystore (keystore文件) -alias (key的別名) -v
(2)查看keystore的公鑰證書信息
keytool -list -keystore (keystore文件) -alias (key的別名) -rfc(注:獲取格式的公鑰證書,RFC 1421)
(3)查看apk的簽名信息
jarsigner -verify -verbose -certs
(4)生成keystore創建keystore,需要用到keytool.exe (位于jdk_xx\jre\bin目錄下),具體做法如下:
keytool -genkey -alias mykey -keyalg RSA -validity 40000 -keystore demo.keystore#說明:# -genkey 產生密鑰# -alias mykey 別名 mykey# -keyalg RSA 使用RSA算法對簽名加密# -validity 40000 有效期限4000天# -keystore demo.keystore
(5)對apk簽名
使用產生的keystore對apk簽名,使用到的是jarsigner.exe ,該工具位于jdk_xx\bin目錄下,命令如下:
jarsigner-verbose-keystoredemo.keystore-signedjartest_signed.apktest.apkmykey# test_signed.apk是簽名之后的文件# test.apk是需要簽名的文件
另外需要注意的是,如果你的jdk版本在1.7以上,你在對apk簽名時,需要加上這個參數:
-digestalg SHA1 -sigalg MD5withRSA
否則同樣會出現:Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]的錯誤。返回搜狐,查看更多
責任編輯:
總結
以上是生活随笔為你收集整理的android studio串号,AndroidStudio使用常见问题集锦的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android 百度大头针,百度地图所有
- 下一篇: 鸿蒙公测报名表填写,鸿蒙公测第二期报名公