Ubuntu環境配置匯總:(七)配置AndroidStudio,androidstudio配置
1. 構建新項目,gradle下載不成功的問題。
建立新項目的時候,提示一直下載gradle,但是無法下載成功。
1)首先,去gradle的官網下載壓縮包。
http://www.gradle.org/downloads
gradle-1.12-all.zip
2)把下載好的gradle-1.12-all.zip拷貝到~/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo
註:如果用AS建立過新的工程,那麼AS會自動建立這個目錄。
3)重新開啟AS,等待AS自動完成gradle的配置。
下面是終端裡面AS的工作日誌,可以看出,首先AS會解壓gradle-1.12-all.zip,然後下載一些依賴的jar。
Unzipping /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12-all.zip to /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uoSet executable permissions for: /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/bin/gradle16:14:10.417 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Tooling API provider 1.12 created.16:14:10.724 [Connection worker] DEBUG o.g.t.i.provider.ProviderConnection - Configuring logging to level: INFOTooling API is using target Gradle version: 1.12.Could not determine classpath for class org.gradle.util.GradleVersionCould not determine classpath for class org.slf4j.LoggerFactoryStarting Gradle daemonStarting daemon process: workingDir = /home/kaizen/.gradle/daemon/1.12, daemonArgs: [/home/kaizen/developer/jdk1.6.0_45/bin/java, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8, -cp, /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/lib/gradle-launcher-1.12.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 1.12, /home/kaizen/.gradle/daemon, 10800000, 57c7e4ac-85a2-40cd-92ea-79aed2105b46, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8]Starting process 'Gradle build daemon'. Working directory: /home/kaizen/.gradle/daemon/1.12 Command: /home/kaizen/developer/jdk1.6.0_45/bin/java -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8 -cp /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/lib/gradle-launcher-1.12.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 1.12 /home/kaizen/.gradle/daemon 10800000 57c7e4ac-85a2-40cd-92ea-79aed2105b46 -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8Successfully started process 'Gradle build daemon'An attempt to start the daemon took 0.662 secs.Connected to the daemon. Dispatching Build{id=9b20f5b5-b8e0-4861-846e-f33d4ded552f.1, currentDir=/home/kaizen/AndroidStudioProjects/MyApplication} request.Download http://jcenter.bintray.com/com/android/tools/build/gradle/0.12.2/gradle-0.12.2.pomDownload http://jcenter.bintray.com/com/android/tools/lint/lint/23.0.2/lint-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/build/builder/0.12.2/builder-0.12.2.pomDownload http://jcenter.bintray.com/com/android/tools/lint/lint-checks/23.0.2/lint-checks-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/sdk-common/23.0.2/sdk-common-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/build/builder-model/0.12.2/builder-model-0.12.2.pomDownload http://jcenter.bintray.com/com/android/tools/ddms/ddmlib/23.0.2/ddmlib-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/build/manifest-merger/23.0.2/manifest-merger-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/sdklib/23.0.2/sdklib-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/common/23.0.2/common-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/build/builder-test-api/0.12.2/builder-test-api-0.12.2.pomDownload http://jcenter.bintray.com/com/android/tools/lint/lint-api/23.0.2/lint-api-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/23.0.2/layoutlib-api-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/dvlib/23.0.2/dvlib-23.0.2.pomDownload http://jcenter.bintray.com/com/android/tools/build/gradle/0.12.2/gradle-0.12.2.jar[ 243945] WARN - api.vfs.impl.local.FileWatcher - Watcher terminated with exit code 0 kaizen@tuan800-inc:~/professional/android-studio/bin$ kaizen@tuan800-inc:~/professional/android-studio/bin$ kaizen@tuan800-inc:~/professional/android-studio/bin$ ./studio.sh Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.Unzipping /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12-all.zip to /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uoSet executable permissions for: /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/bin/gradle16:28:28.487 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Tooling API provider 1.12 created.16:28:28.762 [Connection worker] DEBUG o.g.t.i.provider.ProviderConnection - Configuring logging to level: INFOTooling API is using target Gradle version: 1.12.Could not determine classpath for class org.gradle.util.GradleVersionCould not determine classpath for class org.slf4j.LoggerFactoryStarting Gradle daemonStarting daemon process: workingDir = /home/kaizen/.gradle/daemon/1.12, daemonArgs: [/home/kaizen/developer/jdk1.6.0_45/bin/java, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8, -cp, /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/lib/gradle-launcher-1.12.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 1.12, /home/kaizen/.gradle/daemon, 10800000, b97e7dd0-c6d2-45f6-bb26-3598cdac5ec3, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8]Starting process 'Gradle build daemon'. Working directory: /home/kaizen/.gradle/daemon/1.12 Command: /home/kaizen/developer/jdk1.6.0_45/bin/java -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8 -cp /home/kaizen/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12/lib/gradle-launcher-1.12.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 1.12 /home/kaizen/.gradle/daemon 10800000 b97e7dd0-c6d2-45f6-bb26-3598cdac5ec3 -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8Successfully started process 'Gradle build daemon'An attempt to start the daemon took 0.647 secs.Connected to the daemon. Dispatching Build{id=23bf2872-969b-4499-a311-e96b50cf9695.1, currentDir=/home/kaizen/AndroidStudioProjects/MyApplication} request.Download http://jcenter.bintray.com/com/android/tools/build/gradle/0.12.2/gradle-0.12.2.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint/23.0.2/lint-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder/0.12.2/builder-0.12.2.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint-checks/23.0.2/lint-checks-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/sdk-common/23.0.2/sdk-common-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder-model/0.12.2/builder-model-0.12.2.jarDownload http://jcenter.bintray.com/com/android/tools/ddms/ddmlib/23.0.2/ddmlib-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/build/manifest-merger/23.0.2/manifest-merger-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/sdklib/23.0.2/sdklib-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/common/23.0.2/common-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder-test-api/0.12.2/builder-test-api-0.12.2.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint-api/23.0.2/lint-api-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/23.0.2/layoutlib-api-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/dvlib/23.0.2/dvlib-23.0.2.jarDownload http://jcenter.bintray.com/com/android/tools/build/gradle/0.12.2/gradle-0.12.2-sources.jarDownload http://jcenter.bintray.com/net/sf/proguard/proguard-base/4.11/proguard-base-4.11-sources.jarDownload http://jcenter.bintray.com/net/sf/proguard/proguard-gradle/4.11/proguard-gradle-4.11-sources.jarDownload http://jcenter.bintray.com/com/android/tools/common/23.0.2/common-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/23.0.2/layoutlib-api-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/dvlib/23.0.2/dvlib-23.0.2-sources.jarDownload http://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1-sources.jarDownload http://jcenter.bintray.com/com/android/tools/sdklib/23.0.2/sdklib-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/sdk-common/23.0.2/sdk-common-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder-model/0.12.2/builder-model-0.12.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint-api/23.0.2/lint-api-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint-checks/23.0.2/lint-checks-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/lint/lint/23.0.2/lint-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/ddms/ddmlib/23.0.2/ddmlib-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/build/manifest-merger/23.0.2/manifest-merger-23.0.2-sources.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder-test-api/0.12.2/builder-test-api-0.12.2-sources.jarDownload http://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0-sources.jarDownload http://jcenter.bintray.com/com/android/tools/build/builder/0.12.2/builder-0.12.2-sources.jarBUILD SUCCESSFULTotal time: 2 mins 4.164 secsCreating ClassLoader cda10f2c-7a96-43f6-ac02-439fb293d088 from system and [org.gradle.internal.classloader.FilteringClassLoader@4f816407].Creating ClassLoader 8b556d42-4196-4015-bfce-da42e83769a2 from org.gradle.internal.classloader.MutableURLClassLoader$Spec@35f9a28 and [org.gradle.internal.classloader.FilteringClassLoader@4f816407].Creating ClassLoader 9e1e2c21-8d2b-41c0-8be0-3a6ce81cc7d9 from org.gradle.internal.classloader.MutableURLClassLoader$Spec@f99de5d2 and [org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@30f69f4e].Creating ClassLoader cd6a6514-3fb0-480b-9a70-33a8541439a2 from org.gradle.internal.classloader.MutableURLClassLoader$Spec@ededb07a and [org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@f54d2ff].Creating ClassLoader ff37e9e6-b1e6-4a5e-b18e-287576d9a310 from org.gradle.internal.classloader.MultiParentClassLoader$Spec@a612e20 and [org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@f54d2ff, org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@9e86b36].Creating ClassLoader 7b578a69-cddf-4fdc-95b1-7758c69fbef7 from org.gradle.internal.classloader.CachingClassLoader$Spec@a1369b1c and [org.gradle.internal.classloader.MultiParentClassLoader@79d6ab4e].Creating ClassLoader e709f50c-8ca2-4171-b07f-a1dd73c210cf from org.gradle.internal.classloader.MutableURLClassLoader$Spec@2c03066 and [org.gradle.internal.classloader.CachingClassLoader@7c88cc5f].Creating ClassLoader f910b95f-21b9-4b2d-b43d-28f848b37393 from org.gradle.internal.classloader.FilteringClassLoader$Spec@469d3ae7 and [org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@7921b0d8].Creating ClassLoader 7aaf8593-ee35-4293-84b7-843ba0953f7f from org.gradle.internal.classloader.CachingClassLoader$Spec@a1369b1c and [org.gradle.internal.classloader.FilteringClassLoader@2b1e09a4].Creating ClassLoader bb9fe68f-796f-4102-8b5d-e105b443192d from org.gradle.internal.classloader.MutableURLClassLoader$Spec@811e0f46 and [org.gradle.internal.classloader.CachingClassLoader@410b0419].Creating ClassLoader 66239886-3a13-41f1-8437-e537c3e37cdc from org.gradle.internal.classloader.MutableURLClassLoader$Spec@b572a691 and [org.gradle.tooling.internal.provider.ModelClassLoaderFactory$MixInClassLoader@3a3a26ab].Creating ClassLoader ddf28e42-1797-4bba-8684-077d81c64b2b from org.gradle.internal.classloader.MutableURLClassLoader$Spec@d9326135 and [org.gradle.internal.classloader.CachingClassLoader@410b0419].Tooling API is using target Gradle version: 1.12.Tooling API is using target Gradle version: 1.12.Connected to the daemon. Dispatching Build{id=494ecf74-c1e3-48a1-a1b7-6c91646db023.1, currentDir=/home/kaizen/AndroidStudioProjects/MyApplication} request.Configuration on demand is an incubating feature.:app:preBuild:app:preDebugBuild:app:checkDebugManifest:app:prepareDebugDependencies:app:compileDebugAidl:app:compileDebugRenderscript:app:generateDebugBuildConfig:app:generateDebugAssets UP-TO-DATE:app:mergeDebugAssets:app:generateDebugResValues:app:generateDebugResources:app:mergeDebugResources:app:processDebugManifest:app:processDebugResources:app:generateDebugSourcesBUILD SUCCESSFULTotal time: 3.249 secs
2. 使用gradle編譯安裝apk,出現INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION 的問題。
在AndroidManifest.xml中配置<uses-sdk/>標籤:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
但是,編譯安裝時會報錯。
隨後,發現build.gradle檔案中是這樣配置的:
apply plugin: 'com.android.application'android { compileSdkVersion 19 buildToolsVersion "19.1.0" defaultConfig { applicationId "com.example.kaizen.myapplication" minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])}
修改minSdkVersion 8,重新編譯安裝成功,不再報錯。
ubuntu配置java運行環境
主要就是一點:將Java支援啟動並執行各種目錄、檔案放入環境變數就可以了。
放入環境變數有三種方式,這個你可以自己學習,我推薦是放入目前使用者的環境變數中。
1. cd ~ 也就是切換到目前使用者的根目錄,這個不用解釋了吧。
2. vi .bashrc 這個檔案是目前使用者的一些設定檔,在最後面加入下面的語句
export JAVA_HOME=/usr/java/jdk
#註:上面的/usr/java/jdk是你下載的jdk的目錄,配置java主目錄,後面兩行是加入用行庫的
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3. source .bashrc 加入環境變數,也可以重啟來完成。
好了,試試java命令吧
ubuntu下怎配置配置JAVA 編譯環境
下載JDK,然後裝上就行。裝完要修改/etc/profile或登入使用者的.bashrc檔案,增加環境變數,JAVA_HOME=【安裝JDK的目錄】和修改PATH=$JAVA_HOME/bin:$PATH
要使用IDE的話,下載Eclipse或NetBean linux版就行了。
我也用的這個ubuntu-11.04作業系統