• Tidak ada hasil yang ditemukan

Solusi Error/ Problem Android Studio

BAB 1 Introduction to OpenGL

1.3 Persiapan di Android Studio (AS)

1.3.3 Solusi Error/ Problem Android Studio

Gambar 1.130 Run “MainActivity”

Ketika anda menjalankan pertama kali, jika terdapat Error “JDK”. Maka coba cek di “Variable value:” misal ada jdk yang anda install lebih dari satu versi, dan telah diisikan juga di “Variable value:” misal  “;C:\Program Files\Java\jdk1.7.0_40\bin”, maka anda harus menggantinya dengan versi yang terbaru misal  “;C:\Program Files\Java\jdk1.8.0_31\bin”. Kemudian Klik “Try Again”. Tunggu be- berapa detik.

Gambar 1.131 Edit System Variables JDK 1.8

Gambar 1.132 Launch Emulator (Launch emulator)

 Klik “OK”, jIka ada bug akan tampil seperti ini. Solusinya Klik “Sync Project with Grandle files”

Gambar 1.134 Unexpected Error (Local path doesn't exist) Sync..

Gambar 1.135 Local path doesn't exist (Event Log)

Solusi awal yang dapat dilakukan untuk Error “Local path doesn’t exist” adalah download dengan memasukkan perintah pada terminal “gradlew clean packageDebug” seperti dibawah ini.

Gambar 1.136 Jalankan perintah “gradlew clean packageDebug”

Lalu dengan Klik “Setting”, Klik “Gradle”, kemudian isi “Gradle VM options:” dengan “-Xmx256m”.

Gambar 1.138 isi “Gradle VM options:” dengan “-Xmx256m”

 Check “Edit Configurations….”

Gambar 1.139 Check “Edit Configurations….”

Di dalam “Edit Configurations….””, nama form-nya “Run/Debug Configurations”. Disana terdapat Android Application “app” dan “MainActivity”. Pastikan anda juga telah men-setting seperti pada gambar di bawah ini, terdapat juga “Gradle-aware Make”.

Gambar 1.140 Android Application (app)

 Error ketika running dengan MyAVD (“C:\Users\Imacho\AppData\Local\Android\sdk\tools\emulat or.exe -avd MyAVD -netspeed full -netdelay none emula- tor: ERROR: This AVD's configuration is missing a kernel file!!”)

Gambar 1.142 Failed to complete Gradle execution

Gambar 1.143 ERROR: This AVD's is missing a kernel file

 Error ketika running dengan Nexus 5 API … (“C:\Users\Imacho\AppData\Local\Android\sdk\tools\emulat or.exe -avd Nexus_5_API_21_x86 -netspeed full -netdelay none emulator: ERROR: x86 emulation currently requires hardware acceleration! Please ensure Intel HAXM is properly installed and usable. CPU acceleration status: HAX kernel module is not installed!”)

Gambar 1.144 Failed to complete Gradle execution

Gambar 1.145 ERROR: requires hardware acceleration

Solusinya adalah sebagai berikut :

a. Install HAXM dari path “C:\Users\[Nama Komput- er]\AppData\Local\Android\sdk\extras\intel\Hardware_ Accelerated_Execution_Manager”

Gambar 1.147 intelhaxm-android.exe

Gambar 1.148 Install HAXM 1.1.1

Gambar 1.149 Error launching Android Studio

Solusi dengan men-delete “JAVA_HOME” dari “Environment Variables” , atau dengan menganti variable value “JAVA_HOME” menjadi “C:\Program Files\Java\jdk1.8.0_31\”, solusi ini juga digunakan untuk mengatasi “Failed to complete Gradle execution”. Langkah alternatif ini akan dilakukan pada tahapan kedua.

Gambar 1.151 After Delete “JAVA_HOME”

Gambar 1.152 Error launching Android Studio

Solusi dengan menganti variable value “JAVA_HOME” menjadi “C:\Program Files\Java\jdk1.8.0_31\”, solusi ini juga digunakan untuk mengatasi “Failed to complete Gradle execution”:

 Untuk mengkoneksikan Android Studio + Bluestack, yaitu dengan cara klik kanan file “adb.exe” di path “C:\Users\Imacho\AppData\Local\Android\sdk\platform- tools”, pilih “run as administrator”.

Gambar 1.154 Menghubungkan Android Studio + Bluestack I

Gambar 1.155 Menghubungkan Android Studio + Bluestack II

Proses di atas berjalan sangat cepat, dan hampir tidak terlihat secara jelas oleh mata. Untuk melihatnya, kita bisa menggunakan perintah berikut :

 Menjalankan “cmd.exe” as administrator di “”, lalu men- jalankan file “adb.exe” yang ada pada file “C:\Users\Imacho\AppData\Local\Android\sdk\platform- tools\adb.exe”

Gambar 1.156 Run cmd.exe as Administrator

Gambar 1.157 Run adb.exe by cmd as Administrator

Tabel 1.1 Log “Run adb.exe by cmd as Administrator”

Log ‘‘Run adb.exe by cmd as Administrator’’

Microsoft Windows [Version 6.2.9200]

(c) 2012 Microsoft Corporation. All rights reserved. C:\Windows\system32>cd

C:\Users\Imacho\AppData\Local\Android\sdk\platform- tools

C:\Users\Imacho\AppData\Local\Android\sdk\platform- tools>adb.exe

-a - directs adb to listen on all interfaces for a c

onnection

-d - directs command to the only connected USB devic

e

returns an error if more than one USB device is

present.

-e - directs command to the only running emulator.

returns an error if more than one emulator is r

unning.

-s <specific device> - directs command to the device or emulator with

the given

serial number or qualifier. Overrides ANDROID_S

ERIAL

environment variable. -p <product name or path> - simple product name like 'sooner', or

a relative/absolute path to a product

out directory like 'out/target/product/sooner'.

If -p is not speci- fied, the ANDROID_PRODUCT_OUT

environment variable is used, which must

be an absolute path. -H - Name of adb server host (default: localhost)

-P - Port of adb server (default: 5037)

devices [-l] - list all connected devices

('-l' will also list device qualifiers)

connect <host>[:<port>] - connect to a device via TCP/IP

Port 5555 is used by default if no port number

is specified.

disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.

Port 5555 is used by default if no port number

is specified.

Using this command with no additional arguments

will disconnect from all connected TCP/IP devic

es.

device commands:

adb push [-p] <local> <remote>

- copy file/dir to de- vice

('-p' to display the transfer progress)

adb pull [-p] [-a] <remote> [<local>]

- copy file/dir from device

('-p' to display the transfer progress)

('-a' means copy timestamp and mode)

adb sync [ <directory> ] - copy host->device on- ly if changed

(-l means list but don't copy)

(see 'adb help all') adb shell - run remote shell in- teractively

adb shell <command> - run remote shell com- mand

adb emu <command> - run emulator console command

adb logcat [ <filter-spec> ] - View device log adb forward --list - list all forward socket connections.

the format is a list of lines with the followin

g format:

<serial> " " <lo- cal> " " <remote> "\n"

adb forward <local> <remote> - forward socket con- nections

forward specs are one of:

tcp:<port>

localreserved:<unix domain socket name>

localfilesys- tem:<unix domain socket name>

dev:<character de- vice name>

jdwp:<process pid> (remote only)

adb forward --no-rebind <local> <remote>

- same as 'adb forward <local> <remote>' but fail

s

if <local> is already forwarded

adb forward --remove <local> - remove a specific forward socket connection

adb forward --remove-all - remove all forward socket connections

adb reverse --list - list all reverse socket connections from device

adb reverse <remote> <local> - reverse socket con- nections

reverse specs are one of:

tcp:<port>

localabstract:<unix domain socket name>

localreserved:<unix domain socket name>

localfilesys- tem:<unix domain socket name>

adb reverse --norebind <remote> <local>

- same as 'adb reverse <remote> <local>' but fail

s

if <remote> is al- ready reversed.

adb reverse --remove <remote>

- remove a specific re- versed socket connection

adb reverse --remove-all - remove all reversed socket connections from dev

ice

adb jdwp - list PIDs of process- es hosting a JDWP transport

adb install [-lrtsd] <file>

- push this package file to the device and instal

l it

(-l: forward lock ap- plication)

(-r: replace existing application)

(-t: allow test pack- ages) (-s: install applica- tion on sdcard) (-d: allow version code downgrade) (-p: partial applica- tion install)

adb uninstall [-k] <package> - remove this app pack- age from the device

('-k' means keep the data and cache directories

)

adb bugreport - return all infor- mation from the device

that should be in- cluded in a bug report.

adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]

[-system|-nosystem] [<packages...>]

- write an archive of the device's data to <file>

.

If no -f option is supplied then the data is wr

itten

to "backup.ab" in the current directory.

(-apk|-noapk ena- ble/disable backup of the .apks

themselves

in the archive; the default is noapk.)

(-obb|-noobb ena- ble/disable backup of any insta

lled apk expansion

(aka .obb) files associated with each applic

ation; the default

enable/disable backup of the device's

shared storage / SD card contents; the defau

lt is noshared.)

(-all means to back up all installed applicatio

ns)

(-system|-nosystem toggles whether -all automat

ically includes

system applica- tions; the default is to inclu

de system apps)

(<packages...> is the list of applications to b

e backed up. If

the -all or - shared flags are passed, then t

he package

list is optional. Applications explicitly g

iven on the

command line will be included even if -nosys

tem would

ordinarily cause them to be omitted.)

adb restore <file> - restore device con- tents from the <file> backup

archive

adb help - show this help mes- sage

adb version - show version num scripting:

adb wait-for-device - block until device is online

adb start-server - ensure that there is a server running

adb kill-server - kill the server if it is running

adb get-state - prints: offline | bootloader | device

adb get-serialno - prints: <serial- number>

adb status-window - continuously print device status for a specifie

d device

adb remount - remounts the /system and /vendor (if present) p

artitions on the device read-write

adb reboot [bootloader|recovery] - reboots the de- vice, optionally into the boo

tloader or recovery program

adb reboot-bootloader - reboots the device into the bootloader

adb root - restarts the adbd daemon with root permissions

adb usb - restarts the adbd daemon listening on USB

adb tcpip <port> - restarts the adbd daemon listening on TCP on th

e specified port networking:

adb ppp <tty> [parameters] - Run PPP over USB. Note: you should not automatically start a PPP con- nection.

<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1

[parameters] - Eg. defaultroute debug dump local not- ty usepeerdns

adb sync notes: adb sync [ <directory> ]

<localdir> can be interpreted in several ways: - If <directory> is not specified, /system, /vendor (if present), and /data pa

rtitions will be updated.

- If it is "system", "vendor" or "data", only the corresponding partition

is updated.

environmental variables:

ADB_TRACE - Print debug infor- mation. A comma separated list

of the following values

1 or all, adb, sock- ets, packets, rwx, usb, sync

, sysdeps, transport, jdwp

ANDROID_SERIAL - The serial number to connect to. -s takes prior

logcat option, only these de bug tags are printed.

C:\Users\Imacho\AppData\Local\Android\sdk\platform- tools>

 Setelah run “adb.exe”, lalu lihatlah dari Android Studio apakah Bluestack sudah terkoneksi dengan Android Stu- dio, dengan Klik “Android Device Monitor”

Gambar 1.158 Klik “Android Device Monitor”

 Tunggu beberapa saat, sampai terlihat bahwa Bluestack telah aktif

Gambar 1.160 Success run App (Android Studio + Bluestack)

 Lokasi file *.apk hasil running

 Error lainnya ketika setelah membuat Project baru “Failure [INSTALL_FAILED_OLDER_SDK]”:

Gambar 1.162 INSTALL FAILED OLDER SDK

Solusinya, Masuk ke “Gradle Scripts”, klik “build.gradle(Module:app)” ubah dibagian “compileSdkVer- sion 19”  ubah dibagian “minSdkVersion & tar- getSdkVersion”:

Gambar 1.163 Klik “build.gradle(Module:app)”

Gambar 1.165 Ubah minSdkVersion & targetSdkVersion

Klik pada bagian Gradle files have changed since last pro- ject sync. A project sync may be necessary for the IDE to work properly "Sync Now".

Gambar 1.166 Klik "Sync Now"

Tunggu beberapa detik, maka akan muncul tampilan seperti ini :

Gambar 1.167 Gradle project sync in progress...

Gambar 1.168 Language Level Changed

Error “Files under the build folder are generated and should not be edited” atau

Error “Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.”

Gambar 1.169 Files under the build folder are generated and should not be edited

Ubah “dependencies”.

Copykan file “android-support-v4.jar” ke “D:\ProjectAndroidStudio_2015\B_2_1Primitives_Object\app\libs”.

Gambar 1.171 File android-support-v4.jar

Klik “Sync Now”

Gambar 1.172 Klik “Sync Now”

Atau solusi untuk error “” adalah dengan langkah berikut :

Dalam Android Studio ketika mencoba menggunakan com- pileSdkVersion dan targetSdkVersion of 19, dengan mengubah file “build.gradle” dari :

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat- v7:21.0.3'

}

Setting untuk older version dari appcompat library, menjadi :

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat- v7:19.+'

Jika menggunakan “Setting untuk older version dari appcompat library”, maka anda tanpa perlu melakukan copy paste file “android-

support-v4.jar” ke

D:\ProjectAndroidStudio_2015\B_2_1Primitives_Object\app\libs”.

Gambar 1.173 Setting untuk old version dari appcompat library

Ubah “<style name="AppTheme" par- ent="Theme.AppCompat.Light.DarkActionBar">”  “<style

name="AppTheme" par-

ent="android:Theme.Holo.Light.DarkActionBar">”.

Gambar 1.174 Ubah styles.xml

Jika ada error : Error:(4) No resource identifier found for attrib-

ute 'showAsAction' in package

'com.example.imacho.bbprimitiveobjectblankactivity'. Solusi :

Ubah file “menu_main.xml”

Gambar 1.176 Content Asli "menu_main.xml”

menjadi berikut :

Gambar 1.177 Ubah Content Asli "menu_main.xml”

Kemudian jika terdapat error “Unfortunately, [.Nama Project.] has stopped” saat menjalankan program, maka bisa jadi ada asset yang belum dimasukkan atau bahkan folder assetnya belum dibuat didalam folder main.

Gambar 1.178 Solusi error “Unfortunately, [NamaProject] has stopped”

Berikut tampilan ketika berhasil menjalankan tampilan primitive object :

Cara menghapus Module pada Andorid Studio :

 Klik "File -> Project Structure", lalu Pilih Module yang ingin anda hapus, lalu klik tanda “--”

Gambar 1.180 Project Structure

Gambar 1.181 Remove Module

 Klik “OK”

Gambar 1.183 Klik OK

Gambar 1.184 Delete directory "Nama Project..."

1.3.4 Compare Eclipse dengan Android Studio

Dokumen terkait