Run "Hello World" on your Android Smartphone
1. Install Android Studio on your computer
2. Enable Developer options on S5
3. Download and install Samsung USB driver, you should see it as following in the Device Manager of your computer
5. Create a "Hello World" project in Android Studio
6. Run it and choose running device, and then [OK]
7. I got error:
pkg: /data/local/tmp/com.example.yourname.helloworld
Failure
[INSTALL_FAILED_OLDER_SDK]
The reason is that, in my Samsung phone, the version of API is 19, while in Android Studio, the minSdkVersion is set to 21. To change this, open build.gradle (Module: app), locate defaultConfig:
defaultConfig {
applicationId "com.example.yourname.helloworld"
minSdkVersion 21
targetSdkVersion 21
versionCode
1
versionName
"1.0"
}
Change it to:
defaultConfig {
applicationId "com.example.yourname.helloworld"
minSdkVersion 19
targetSdkVersion 21
versionCode
1
versionName
"1.0"
}
Run it again, I see "Hello world!" on my phone!
If you still get the same error, you can further lower the version number, make sure the minSdkVersion is not lower than the API version of your Android phone.
I ran it on my Samsung Galaxy S5, and I would assume the above steps would be very similar on other Android Phones.