Saturday, March 25, 2023

How to install Android SDK platform tools and AVD on Windows 10 with Apache Netbeans

Android SKD (Software Development Kit) merupakan alat yang digunakan oleh para developer aplikasi mobile untuk mengembangkan aplikasi berbasis Android. Perangkat lunak ini dikembangkan oleh Google untuk platform Android. Di dalamnya, terdapat beberapa tools seperti debugger, emulator, documentations, sample code, software libraries, dan tutorial-tutorial yang memudahkan pengembang aplikasi.

Java SE Development kit salah satu contoh dari Android SDK dan menjadi bahasa pemrograman yang paling sering digunakan untuk mengembangkan aplikasi Android. Ada beberapa bahasa lainnya seperti C++, Go, Groovy, Java, dan Kotlin yang dapat menjadi bahasa pemrograman yang memudahkan pengembang dalam membuat aplikasi berbasis mobile.




Sebagai bahan bacaan, kawan-kawan dapat mencarinya pada beberapa link berikut:

https://github.com/NBANDROIDTEAM/NBANDROID-V2 

https://www.oracle.com/java/technologies/downloads/#java11-windows

https://netbeans.apache.org/download/nb111/nb111.html

https://developer.android.com/studio/releases/gradle-plugin#compatibility-7-4-0 

https://developer.android.com/distribute/google-play/resources/icon-design-specifications 

https://developer.android.com/studio/run/emulator-acceleration#vm-windows-whpx 

https://learn.microsoft.com/id-id/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v 


Build Android Studio app via command line

Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the gradlew script found in the root of your project (or gradlew.bat on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run ./gradlew assembleDebug or gradlew debug from the root of your repository. In a default project setup, the resulting apk can then be found in app/build/outputs/apk/app-debug.apk. On a *nix machine, you can also just run find . -name '*.apk' to find it, if it's not there.


Failed to resolve: com.android.support:appcompat-v7:33.++

My suggestion is implement com.android.support:appcompat-v7:28.0.0 refer to https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml or by enable jetifire by adding the line below to your gradle.properties file

android.enableJetifier=true


error: package android.support.v7.widget does not exist import

use AndroidX library, add implementation 'androidx.appcompat:appcompat:1.1.0' in your app build.gradle (in app folder/ sub project). Then write

import androidx.appcompat.widget.Toolbar in class and replace <android.support.v7.widget.Toolbar/> with <androidx.appcompat.widget.Toolbar/> in XML layout.


error: method does not override or implement a method from a supertype     @Override



Android Gradle Plugin with Gradle version

When you update Android Studio, you may receive a prompt to also update Gradle to the latest available version. You can choose to accept the update or manually specify a version based on your project's build requirements. https://developer.android.com/studio/releases/gradle-plugin#updating-gradle . The following example sets the Gradle version to 7.5 using the Gradle Wrapper. Note, you need to run this command twice to upgrade both Gradle and the Gradle Wrapper itself (for more information, see Upgrading the Gradle Wrapper).

gradle wrapper --gradle-version 7.5

However this might fail in some cases, for example if you've just updated AGP and it's no longer compliant with the current Gradle version. In this case, you need to edit the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file. The following example sets the Gradle version to 7.5 in the gradle-wrapper.properties file.

...

distributionUrl = https\://services.gradle.org/distributions/gradle-7.5-bin.zip

...


Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file 

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

Open local.properties file and paste your Android SDK path like below:

For Windows users:

sdk.dir=C:\\Users\\User-PC\\AppData\\Local\\Android\\sdk

or (for newer versions of Android Studio / IntelliJ IDEA):

sdk.dir=C\:\\Users\\User-PC\\AppData\\Local\\Android\\sdk

Make sure the folder is sdk or Sdk.

For Mac users:

sdk.dir = /Users/USERNAME/Library/Android/sdk

Where USERNAME is your OSX username.

For Linux (Ubuntu) users:

sdk.dir = /home/USERNAME/Android/Sdk

Where USERNAME is your linux username (Linux paths are case-sensitive: make sure the case of S in Sdk matches) 


java source base version 4 netbeans plugins

Downgrade to Apache Netbeans-11.1 nd JDK 11 https://www.oracle.com/java/technologies/downloads/#java11-windows https://netbeans.apache.org/download/nb111/nb111.html


send file to android emulator or How to copy files to Android emulator instance or transfer files to android emulator from pc

One easy way is to drag and drop. It will copy files to /sdcard/Download. You can copy whole folders or multiple files. Make sure that "Enable Clipboard Sharing" is enabled. (under ...-> Settings)


buildtoolsversion for compilesdkversion or Android gradle: buildtoolsVersion vs compileSdkVersion

compileSdkVersion is the API version of Android that you compile against. buildToolsVersion is the version of the compilers (aapt, dx, renderscript compiler, etc...) that you want to use. For each API level (starting with 18), there is a matching .0.0 version.

At IO 2014, we release API 20 and build-tools 20.0.0 to go with it. see it in build.gradle:

android {
  compileSdkVersion 32
  buildToolsVersion '30.0.3'
....
}

Between Android releases we will release updates of the compilers, and so we'll release version .0.1, .0.2, etc... Because we don't want to silently update these version under you, it's up to you to move to the new version when it's convenient for you. You can use a higher version of the build-tools than your compileSdkVersion, in order to pick up new/better compiler while not changing what you build your app against.


Configure VM acceleration using Windows Hypervisor Platform

https://developer.android.com/studio/run/emulator-acceleration#vm-windows-whpx or https://learn.microsoft.com/id-id/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v 
https://github.com/intel/haxm, https://github.com/intel/haxm/releases, https://github.com/intel/haxm/blob/master/docs/manual-windows.md, https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads?source=recommendations


Can I run Android Studio (Android SDK emulator) in a Microsoft hyper-v virtual machine?

Refer to this link: How to run Android Studio on Windows without disabling Hyper-V. The solution (if you do not want to disable Hyper-V) is to use Microsoft’s Android emulator, which is a free download here. In order to use this with Android Studio, you need to run the emulator first. Then, in Android Studio, go to Run > Edit Configurations... and select Show Device Chooser Dialog under Deployment Target Options. Run your project, and select the VS Emulator, ignoring the invitation to “Turn off Hyper-V”.


Fully change package name including company domain

current package : com.company.name 
New package : com.mycomapny.name 
Steps: 1) Suppose you are at this screen which is shown below. 
enter image description here
2) Open project pane and click on settings icon.
3) Deselect Compact Empty Middle Packages.
4) Then your package is now broken into individual parts as shown below.
5) right click on "company" select Refactor -> select rename ->rename directory.
6) Now your "company" has been changed to new "mycomapny" and changes.
7) Now change the package name in AndroidManifest.xml file.
8) Open app level build.gradle and change package name.
9) you will get errors as Cannot resolve symbol "R".
10) Remove line which gives this error and studio will import new R file automatically.
11) If you have multiple files then use find and replace option by pressing " Cntrl+Shift+R ".
Or " Select Edit->Find->Replace in path.."
12) select Replace All.

or change the package name manually in the manifest file. Click on your R.java class and the press F6 (Refactor->Move...). It will allow you to move the class to other package, and all references to that class will be updated.


No comments:

Post a Comment