opensuse15.4安装android_studio再运行微信apk_未完成
未完成的原因是:本人台式机的物理内存为4G,官方要求是16G
android studio与android sdkj是两个完全不同的两样东西。
Android studio是一个IDE(可视化开发工具)跟eclipse一样的东西,用来开发Android的工具。它是Google基于IntelliJ IDEA重新开发的免费工具。Google正在力推开发者用studio来替换eclipse开发。
Android SDK 是一个开发包。类似于JAVA SDK。里面包含了Android开发的各式各样的库文件。
android studio需要安装sdk。Android studio安装完后会自带 sdk 的,如果没有 sdk 的话,程序是无法编译运行的,sdk的路径自己可以修改。
注意:要试遍以下内容需要home目录所在的磁盘分区要有大于5GB的可用空间
ruhong@localhost:~> df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda8 12G 5.8G 5.2G 53% /home
应用程序——工具——磁盘使用情况分析器——home目录所在的磁盘分区——转移占用空间的大文件或者手工删除一些程序的缓存文件夹
一、查看当前系统的JAVA版本
ruhong@localhost:~> java -version
openjdk version “11.0.15” 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-suse-150000.3.80.1-x8664)
OpenJDK 64-Bit Server VM (build 11.0.15+10-suse-150000.3.80.1-x8664, mixed mode)
二、安装android studio
到https://software.opensuse.org/输入关键字android studio搜索——openSUSE Leap 15.4显示社区软件包——Exper Download——openSUSE——直接抓取二制软件包——android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm大小为729MB——保存文件
ruhong@localhost:~> su -
密码:
切换到root用户并输入密码
localhost:~ # zypper install /run/media/ruhong/3E76516276511BC9/opensuse15.3rpms/download/android-studio-202
android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm
android-studio-2022.1.1.19-linux.tar.gz
localhost:~ # zypper install /home/ruhong/download/android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm
Loading repository data…
Reading installed packages…
Resolving package dependencies…
The following NEW package is going to be installed:
android-studio
1 new package to install.
Overall download size: 729.5 MiB. Already cached: 0 B. After the operation, additional 1.7 GiB will be used.
Continue? [y/n/v/…? shows all options] (y): y 输入字母y再按回车键
Retrieving package android-studio-2021.1.1.23-lp154.71.1.x86_64 (1/1), 729.5 MiB ( 1.72 GiB unpacked)
android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID 1568f7d6782e2fc1: NOKEY
V3 RSA/SHA256 Signature, key ID 1568f7d6782e2fc1: NOKEY
warning: /var/tmp/zypp.6RXedx/zypper/tmpRPMcache/%CLI%/android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 782e2fc1: NOKEY
Looking for gpg key ID 782E2FC1 in cache /var/cache/zypp/pubkeys.
Repository Plain RPM files cache does not define additional ‘gpgkey=’ URLs.
android-studio-2021.1.1.23-lp154.71.1.x86_64 (Plain RPM files cache): Signature verification failed [4-Signatures public key is not available]
Abort, retry, ignore? [a/r/i] (a): i 输入字母再按回车键
Checking for file conflicts: …[done]
warning: /var/cache/zypper/RPMS/android-studio-2021.1.1.23-lp154.71.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 782e2fc1: NOKEY
(1/1) Installing: android-studio-2021.1.1.23-lp154.71.1.x86_64 …[done]
应用程序——编程——Android Studio
第一次出现对话框Unable to access Android SDK add-on list就单击Setup Proxy——单击Auto-detect proxy settings——勾选Automatic proxy configuration URL——粘贴http://mirrors.neusoft.edu.cn/
查网上有提供其它地址,单击Check connection——粘贴网址单击ok——如果可用就会跳出提示Connection successful
第二次出现对话框Unable to access Android SDK add-on list就单击Cancel——之后就是默认单击Next和Accept,会自动下载sdk
https://dl.google.com/android/repository/platform-33-ext4_r01.zip
https://dl.google.com/android/repository/3534162-studio.sdk-patcher.zip
https://dl.google.com/android/repository/emulator-linux_x64-9322596.zip
https://dl.google.com/android/repository/platform-tools_r33.0.3-linux.zip
https://dl.google.com/android/repository/build-tools_r33.0.1-linux.zip
主要参考这两个文章
《unable to access android sdk add-on list解决方案》
https://blog.csdn.net/qq_35892584/article/details/109746886
《Android SDK 国内好用的下载方法》
https://zhuanlan.zhihu.com/p/34775112
单击More Actions——SDK Manager——SDK Tools,可以看到它已经安装了什么
openSUSE Leap 15.4是 64 位版本的,需要安装一些 32 位库
localhost:~ # zypper install zlib-devel-32bit ncurses-devel-32bit ncurses5-devel-32bit bzip2
三、新建一个工程项目
New Project——Empty Activity——Name改为cellphone——Language改为java——Finish
报错提示Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
ruhong@localhost:~> cat /home/ruhong/AndroidStudioProjects/cellphone/gradle/wrapper/gradle-wrapper.properties
#Wed Jan 18 17:56:12 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
就使用浏览器下载 https://services.gradle.org/distributions/gradle-7.2-bin.zip文件大小为110MB
文件位置为/home/ruhong/download/gradle-7.2-bin.zip
ruhong@localhost:~> vim /home/ruhong/AndroidStudioProjects/cellphone/gradle/wrapper/gradle-wrapper.properties
用文本编辑器vim将这行
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-bin.zip
改为
distributionUrl=file:///home/ruhong/download/gradle-7.2-bin.zip
关闭Android Studio再打开
四、创建手机虚拟设备AVD
Tools——Device Manager——Create device——保持默认Phone、Pixel2——单击Android 11.0 (Google Play)最左边的Download——下载x86-30-r09-linux.zip大小为1.1GB——单击Pixel 2 API 30所在蓝色条右边的三角符号表示运行手机虚拟设备
https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86-30_r09-linux.zip
ruhong@localhost:~> du -sh /home/ruhong/Android/Sdk/system-images/android-30
2.5G /home/ruhong/Android/Sdk/system-images/android-30
报错提示the emulator process for avd pixel_2_API_30 has terminated
参考以下文章得知,home目录所在的磁盘分区sda8已经满了,没有多余空间运行虚拟设备AVD,而磁盘分区sda5是比较空闲的,在sda5分区创建文件夹android_AVD,将虚拟设备AVD
《Android Studio不能启动模拟器原因探秘 The emulator process for AVD xxx has terminated》
https://www.cnblogs.com/fly263/p/16181714.html
ruhong@localhost:~> df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda7 20G 16G 3.3G 83% /
/dev/sda5 20G 6.9G 12G 38% /mnt/sda5
/dev/sda8 12G 11G 396M 97% /home
ruhong@localhost:~> su -
密码:
localhost:~ # mkdir /mnt/sda5/android_AVD
localhost:~ # ls -ld /mnt/sda5/android_AVD/
drwxr-xr-x 2 root root 4096 Jan 19 23:49 /mnt/sda5/android_AVD/
localhost:~ # id ruhong
uid=1000(ruhong) gid=100(users) groups=100(users)
localhost:~ # chown ruhong.users /mnt/sda5/android_AVD/
ruhong@localhost:~> cp -ar .android/ /mnt/sda5/android_AVD/
ruhong@localhost:~> ls /mnt/sda5/android_AVD/.android/
adb.5037 adbkey.pub avd cache debug.keystore.lock
adbkey analytics.settings breakpad debug.keystore
ruhong@localhost:~> vim .bashrc
用文本编辑器vim编辑/home/ruhong/.bashrc在最后加上这2行内容
export PATH=$PATH:/home/ruhong/Android/Sdk/platform-tools
export ANDROID_SDK_HOME=/mnt/sda5/android_AVD
ruhong@localhost:~> source .bashrc
ruhong@localhost:~> echo $ANDROID_SDK_HOME
/mnt/sda5/android_AVD
关闭android studio再打开仍然默认为/home/ruhong/.android,还是要重启一次计算机
删除之前创建的Pixel_2_API_30,再重新创建一个Pixel_2_API_30
Show on Disk会自动打开文件夹/mnt/sda5/android_AVD/.android/avd/Pixel_2_API_30.avd/
报错提示timed out after 300seconds waiting for emulator to come online
ruhong@localhost:~> cat /home/ruhong/AndroidStudioProjects/cellphone/app/build.gradle
plugins {
id ‘com.android.application’
}
android {
compileSdk 33
defaultConfig {
applicationId "com.example.cellphone"
minSdk 21
targetSdk 33
显示最低运行API 21和最高运行API 33
Tools——SDK Manager——SDK Platforms——勾选Android 11.0®——Apply
自动下载并安装
https://dl.google.com/android/repository/sources-30_r01.zip
https://dl.google.com/android/repository/platform-30_r03.zip
仍然会报错提示timed out after 300seconds waiting for emulator to come online
原因是本人台式机的物理内存为4G,官方要求是
模拟器的系统要求
为获得最佳体验,您应在至少满足以下规格的计算机上使用 Android Studio 中的模拟器:
16 GB RAM
64 位 Windows、macOS、Linux 或 ChromeOS 操作系统
16 GB 磁盘可用空间
请参考https://developer.android.google.cn/studio/run/emulator?hl=zh-cn
https://weixin.qq.com/
下载微信的android版本
默认下载64位的https://dldir1.qq.com/weixin/android/weixin8032android2300_arm64_3.apk
也可以下载32位的https://dldir1.qq.com/weixin/android/weixin8032android2300_3.apk
ruhong@localhost:~/download> cp weixin8032android2300_arm64_3.apk /home/ruhong/Android/Sdk/platform-tools/
ruhong@localhost:~/download> cd
ruhong@localhost:~> cd /home/ruhong/Android/Sdk/platform-tools/
ruhong@localhost:~/Android/Sdk/platform-tools> ls
adb lib64 package.xml
dmtracedump make_f2fs sload_f2fs
e2fsdroid make_f2fs_casefold source.properties
etc1tool mke2fs sqlite3
fastboot mke2fs.conf weixin8032android2300_arm64_3.apk
hprof-conv NOTICE.txt
========================================================================================================
就卡住在这里了,只有4G 内存而没有16G无法运行模拟器,模拟手机处于开机状态,才能使用adb install xxxx.apk安装程序并运行
ruhong@localhost:~/Android/Sdk/platform-tools> ./adb install weixin8032android2300_arm64_3.apk
《Android Studio模拟器如何运行apk文件》
https://blog.csdn.net/qq_48211069/article/details/123918040
《Android Studio安卓模拟器安装本地APK》
https://blog.csdn.net/qq_34707272/article/details/107831400
用户指南
https://developer.android.google.cn/studio/workflow
如果要删除工程项目和android studio请按以下命令删除,将会释放几GB磁盘空间
ruhong@localhost:~> rm -rf Android/
ruhong@localhost:~> rm -rf AndroidStudioProjects/
ruhong@localhost:~> rm -rf .config/Android\ Open\ Source\ Project/
ruhong@localhost:~> rm -rf .config/Google/
ruhong@localhost:~> rm -rf .android/
ruhong@localhost:~> rm -rf .gradle/
ruhong@localhost:~> rm -rf .cache/*
ruhong@localhost:~> su -
密码:
切换到root用户并输入密码
localhost:~ # zypper remove android-studio-2021.1.1.23-lp154.71.1.x86_64