Android

Linux download https://dl.google.com/dl/android/studio/ide-zips/3.5.1.0/android-studio-ide-191.5900203-linux.tar.gz

   1 cp android-studio-ide-191.5900203-linux.tar.gz /opt/
   2 cd /opt/
   3 tar xvzf android-studio-ide-191.5900203-linux.tar.gz 
   4 chgrp users android-studio/ -R
   5 /opt/android-studio/bin/studio.sh
   6 ###
   7 Preparing "Install Android SDK Tools (revision: 26.1.1)".
   8 Downloading https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
   9 "Install Android SDK Tools (revision: 26.1.1)" ready.
  10 Installing Android SDK Tools in /home/vitor/Android/Sdk/tools
  11 "Install Android SDK Tools (revision: 26.1.1)" complete.
  12 "Install Android SDK Tools (revision: 26.1.1)" finished.
  13 Preparing "Install SDK Patch Applier v4 (revision: 1)".
  14 Downloading https://dl.google.com/android/repository/3534162-studio.sdk-patcher.zip
  15 "Install SDK Patch Applier v4 (revision: 1)" ready.
  16 Installing SDK Patch Applier v4 in /home/vitor/Android/Sdk/patcher/v4
  17 "Install SDK Patch Applier v4 (revision: 1)" complete.
  18 "Install SDK Patch Applier v4 (revision: 1)" finished.
  19 Preparing "Install Android Emulator (revision: 29.2.1)".
  20 Downloading https://dl.google.com/android/repository/emulator-linux-5889189.zip
  21 "Install Android Emulator (revision: 29.2.1)" ready.
  22 Installing Android Emulator in /home/vitor/Android/Sdk/emulator
  23 "Install Android Emulator (revision: 29.2.1)" complete.
  24 "Install Android Emulator (revision: 29.2.1)" finished.
  25 Preparing "Install Android SDK Platform-Tools (revision: 29.0.4)".
  26 Downloading https://dl.google.com/android/repository/platform-tools_r29.0.4-linux.zip
  27 "Install Android SDK Platform-Tools (revision: 29.0.4)" ready.
  28 Installing Android SDK Platform-Tools in /home/vitor/Android/Sdk/platform-tools
  29 "Install Android SDK Platform-Tools (revision: 29.0.4)" complete.
  30 "Install Android SDK Platform-Tools (revision: 29.0.4)" finished.
  31 Preparing "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)".
  32 Downloading https://dl.google.com/android/repository/build-tools_r29.0.2-linux.zip
  33 "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" ready.
  34 Installing Android SDK Build-Tools 29.0.2 in /home/vitor/Android/Sdk/build-tools/29.0.2
  35 "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" complete.
  36 "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" finished.
  37 Preparing "Install Android SDK Platform 29 (revision: 3)".
  38 Downloading https://dl.google.com/android/repository/platform-29_r03.zip
  39 "Install Android SDK Platform 29 (revision: 3)" ready.
  40 Installing Android SDK Platform 29 in /home/vitor/Android/Sdk/platforms/android-29
  41 "Install Android SDK Platform 29 (revision: 3)" complete.
  42 "Install Android SDK Platform 29 (revision: 3)" finished.
  43 Preparing "Install Sources for Android 29 (revision: 1)".
  44 Downloading https://dl.google.com/android/repository/sources-29_r01.zip
  45 "Install Sources for Android 29 (revision: 1)" ready.
  46 Installing Sources for Android 29 in /home/vitor/Android/Sdk/sources/android-29
  47 "Install Sources for Android 29 (revision: 1)" complete.
  48 "Install Sources for Android 29 (revision: 1)" finished.
  49 Parsing /home/vitor/Android/Sdk/build-tools/29.0.2/package.xml
  50 Parsing /home/vitor/Android/Sdk/emulator/package.xml
  51 Parsing /home/vitor/Android/Sdk/patcher/v4/package.xml
  52 Parsing /home/vitor/Android/Sdk/platform-tools/package.xml
  53 Parsing /home/vitor/Android/Sdk/platforms/android-29/package.xml
  54 Parsing /home/vitor/Android/Sdk/sources/android-29/package.xml
  55 Parsing /home/vitor/Android/Sdk/tools/package.xml
  56 Android SDK is up to date.

Android SDK linux command line tools

   1 cd /opt
   2 wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
   3 tar xvzf android-sdk_r24.4.1-linux.tgz
   4 cd android-sdk-linux/tools
   5 ./android list sdk

   1- Android SDK Tools, revision 25.1.7
   2- Android SDK Platform-tools, revision 24.0.2
   3- Android SDK Build-tools, revision 24.0.2
  13- SDK Platform Android 4.1.2, API 16, revision 5

   1 ./android update sdk --no-ui --filter 1,2,3,13
   2 cd ../tools
   3 ./android create project --target android-16 --name AndroidProj --path ~/tmp/androidProj/ --activity MyProject --package androidproj.test --gradle --gradle-version 1.1.0
   4 # 1.1.0 is the gradle plugin version
   5 cd ~/tmp/androidProj

Project structure

.
|-- build.gradle
|-- gradle
|   `-- wrapper
|       |-- gradle-wrapper.jar
|       `-- gradle-wrapper.properties
|-- gradlew
|-- gradlew.bat
|-- local.properties
`-- src
    |-- androidTest
    |   `-- java
    |       `-- androidproj
    |           `-- test
    |               `-- MyProjectTest.java
    `-- main
        |-- AndroidManifest.xml
        |-- java
        |   `-- androidproj
        |       `-- test
        |           `-- MyProject.java
        `-- res
            |-- drawable-hdpi
            |   `-- ic_launcher.png
            |-- drawable-ldpi
            |   `-- ic_launcher.png
            |-- drawable-mdpi
            |   `-- ic_launcher.png
            |-- drawable-xhdpi
            |   `-- ic_launcher.png
            |-- layout
            |   `-- main.xml
            `-- values
                `-- strings.xml

   1 vi gradle/wrapper/gradle-wrapper.properties # change version from 1.12 to 2.2.1
   2 vi build.gradle # comment with // lines with Proguard
   3 ./gradlew
   4 ./gradlew tasks
   5 ./gradlew clean build
   6 find . -name "*.apk" # ./build/outputs/apk/androidProj-debug.apk
   7 

./build/outputs/apk/androidProj-debug.apk
./build/outputs/apk/androidProj-release-unsigned.apk
./build/outputs/apk/androidProj-debug-unaligned.apk

./src/androidTest/java/androidproj/test/MyProjectTest.java

   1 package androidproj.test;
   2 
   3 import android.test.ActivityInstrumentationTestCase2;
   4 
   5 /**
   6  * This is a simple framework for a test of an Application.  See
   7  * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
   8  * how to write and extend Application tests.
   9  * <p/>
  10  * To run this test, you can type:
  11  * adb shell am instrument -w \
  12  * -e class androidproj.test.MyProjectTest \
  13  * androidproj.test.tests/android.test.InstrumentationTestRunner
  14  */
  15 public class MyProjectTest extends ActivityInstrumentationTestCase2<MyProject> {
  16 
  17     public MyProjectTest() {
  18         super("androidproj.test", MyProject.class);
  19     }
  20 
  21 }

./src/main/AndroidManifest.xml

   1 <?xml version="1.0" encoding="utf-8"?>
   2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
   3       package="androidproj.test"
   4       android:versionCode="1"
   5       android:versionName="1.0">
   6     <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
   7         <activity android:name="MyProject"
   8                   android:label="@string/app_name">
   9             <intent-filter>
  10                 <action android:name="android.intent.action.MAIN" />
  11                 <category android:name="android.intent.category.LAUNCHER" />
  12             </intent-filter>
  13         </activity>
  14     </application>
  15 </manifest>

./src/main/res/layout/main.xml

   1 <?xml version="1.0" encoding="utf-8"?>
   2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   3     android:orientation="vertical"
   4     android:layout_width="fill_parent"
   5     android:layout_height="fill_parent"
   6     >
   7 <TextView
   8     android:layout_width="fill_parent"
   9     android:layout_height="wrap_content"
  10     android:text="Hello World, MyProject"
  11     />
  12 </LinearLayout>

./src/main/res/values/strings.xml

   1 <?xml version="1.0" encoding="utf-8"?>
   2 <resources>
   3     <string name="app_name">MyProject</string>
   4 </resources>

./src/main/java/androidproj/test/MyProject.java

   1 package androidproj.test;
   2 
   3 import android.app.Activity;
   4 import android.os.Bundle;
   5 
   6 public class MyProject extends Activity
   7 {
   8     /** Called when the activity is first created. */
   9     @Override
  10     public void onCreate(Bundle savedInstanceState)
  11     {
  12         super.onCreate(savedInstanceState);
  13         setContentView(R.layout.main);
  14     }
  15 }

./build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}
apply plugin: 'android'

android {
    compileSdkVersion 'android-16'
    buildToolsVersion '24.0.2'

    buildTypes {
        release {
            //runProguard false
            // proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
}

./gradle/wrapper/gradle-wrapper.properties

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

Vodafone 785 Slackware

libmtp version: 1.1.11

Listing raw device(s)
Device 0 (VID=1bbb and PID=0168) is a Alcatel 6030a.
   Found 1 device(s):
   Alcatel: 6030a (1bbb:0168) @ bus 1, dev 7
Attempting to connect device(s)
Android device detected, assigning default bug flags

   1 cd /tmp
   2 wget https://slackbuilds.org/slackbuilds/13.37/multimedia/mtpfs.tar.gz
   3 tar xvzf mtpfs.tar.gz
   4 cd mtpfs
   5 wget http://www.adebenham.com/debian/mtpfs_0.9.orig.tar.gz
   6 ./mtpfs.SlackBuild
   7 installpkg  /tmp/mtpfs-0.9-i486-1_SBo.tgz
   8 mtpfs -o allow_other /mnt/tmp/

mtp-folders
Attempting to connect device(s)
Device 0 (VID=1bbb and PID=0167) is a Alcatel/TCT 6010D/TCL S950.
mtp-folders: Successfully connected


mtp-files > /tmp/files.txt
mtp-folders > /tmp/folders.txt

Android SDK - command line tools

   1 cd ~
   2 wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
   3 tar xvzf OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
   4 jdk8u222-b10/bin/java -version
   5 
   6 cd ~
   7 mkdir android
   8 cd android/
   9 wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
  10 unzip commandlinetools-linux-6858069_latest.zip
  11 cd cmdline-tools/
  12 mkdir latest
  13 mv bin/ lib/ NOTICE.txt  source.properties latest/
  14 cd ..
  15 cmdline-tools/latest/bin/sdkmanager --update
  16 cmdline-tools/latest/bin/sdkmanager --version
  17 # install build tools 19.1.0
  18 cmdline-tools/latest/bin/sdkmanager --install "build-tools;19.1.0"
  19 
  20 export ANDROID_HOME=/home/vitor/android/
  21 export ANDROID_SDK_ROOT=/home/vitor/android/
  22 export PATH=/usr/local/bin:/usr/bin:/bin:/home/vitor/jdk8u222-b10/bin
  23 # requires jdk8
  24 export JAVA_HOME=/home/vitor/jdk8u222-b10/
  25 
  26 cmdline-tools/latest/bin/sdkmanager --list
  27 Installed packages:=====================] 100% Computing updates...
  28   Path                 | Version | Description                    | Location
  29   -------              | ------- | -------                        | -------
  30   build-tools;19.1.0   | 19.1.0  | Android SDK Build-Tools 19.1   | build-tools/19.1.0/
  31   build-tools;28.0.3   | 28.0.3  | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/
  32   emulator             | 30.1.5  | Android Emulator               | emulator/
  33   patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4/
  34   platform-tools       | 30.0.5  | Android SDK Platform-Tools     | platform-tools/
  35   platforms;android-28 | 6       | Android SDK Platform 28        | platforms/android-28/

Docker environment

   1 mkdir target
   2 nano Dockerfile

FROM ubuntu:20.04
RUN apt update
RUN apt-get install -y curl sudo wget 
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt install -y nodejs unzip gradle curl sudo 
RUN mkdir /app
#RUN mkdir -p /root/Downloads
#RUN cd ~/Downloads
RUN wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
RUN tar xvzf OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz
RUN mv jdk8u222-b10/ ~
RUN mkdir ~/android
RUN unzip commandlinetools-linux-6858069_latest.zip
RUN mv cmdline-tools/ ~/android/
RUN cd ~/android/cmdline-tools/ && mkdir latest && mv bin/ lib/ NOTICE.txt  source.properties latest/
RUN echo "export ANDROID_HOME=/root/android/" >> ~/.bashrc
RUN echo "export ANDROID_SDK_ROOT=/root/android/" >> ~/.bashrc
RUN echo "export PATH=/usr/local/bin:/usr/bin:/bin:/root/jdk8u222-b10/bin" >> ~/.bashrc
RUN echo "export JAVA_HOME=/root/jdk8u222-b10/" >> ~/.bashrc
RUN cat ~/.bashrc 
RUN /root/android/cmdline-tools/latest/bin/sdkmanager --update
RUN /root/android/cmdline-tools/latest/bin/sdkmanager --version
RUN yes | /root/android/cmdline-tools/latest/bin/sdkmanager --install "build-tools;19.1.0"
RUN /root/android/cmdline-tools/latest/bin/sdkmanager --list # should show installed packages
RUN echo "#!/bin/sh\n tail -f /etc/passwd" > /start.sh
CMD ["sh","/start.sh"]

   1 docker build -t env-docker-image . 
   2 docker run -p 8081:8081 -d -it --rm --name env-docker-container --mount type=bind,source="$(pwd)"/target,target=/app env-docker-image
   3 docker ps
   4 docker exec -it 27868e5016fd bash

Java/Android (last edited 2023-05-26 15:59:08 by 127)