`
sillycat
  • 浏览: 2542004 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Android with Emulator Shell

 
阅读更多
Android with Emulator Shell

1. Change the HOSTS
First step, start my emulator.

Then, remount the device image as writable
>adb remount

Then, save a copy of the hosts file on my own machine
>adb pull /system/etc/hosts /Users/carl/data

Then, edit the hosts as I like

Then, save and push back the hosts file to the emulator
>adb push /Users/carl/data/hosts /system/etc

2. Connect to HTTPS
Error Message when I try to connect to HTTPS
POST: javax.net.ssl.SSLException: Not trusted server certificate
javax.net.ssl.SSLException: Not trusted server certificate

Solution:
Some solutions are about disable the SSL based on HTTP-Client or KSOAP2.
Disable SSL check based on HTTPCLIENT
http://blog.syedgakbar.com/2012/07/21/android-https-and-not-trusted-server-certificate-error/
Disable SSL check based on ksoap2
http://lanyan-lan.iteye.com/blog/1523821

But I am planning to install the CERT on my emulator.
http://intrepidusgroup.com/insight/2011/08/setting-up-a-persistent-trusted-ca-in-an-android-emulator/

Step 1: Set up OS environment
Android is using a specific keystone type called Bouncycastle KeyStore(BKS).
I download the jar package and place it in my JAVA_HOME lib directory
http://www.bouncycastle.org/archive/141/bcprov-jdk16-141.jar

On my MAC laptop, the directory is here:
/System/Library/Frameworks/JavaVM.framework/Home/lib/ext

>cd /System/Library/Frameworks/JavaVM.framework/Home/lib/ext
>sudo cp /Users/carl/data/bcprov-jdk16-141.jar ./

Try to manually install the CERT
>adb pull /system/etc/security/cacerts.bks /Users/carl/data/

Prepare the CERT file, open the URL with Firefox.
[Add Exception…] ---> [View] ---> [Details] ----> [Export] ----> File name sillycat with [X.509 Certificate (PEM)]
>cd /Users/carl/data
>mv sillycat sillycat.cert
Check the certificate file
>keytool -printcert -file sillycat.cer

Example:
keytool -keystore cacerts.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -importcert -trustcacerts -alias somealias -file ca.cer -noprompt

>keytool -keystore cacerts.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -importcert -trustcacerts -alias sillycat -file sillycat.cer -noprompt

I used to think that I do not have password, so I get rid of the line -storepass changeit, I got
Error Message:
keytool error: java.lang.NullPointerException
Solution:
The default password is changeit, but not empty.

Change the permission on AVD
>adb shell chmod 777 /system/etc/security/cacerts.bks

Push the changed file to AVD
>adb push cacerts.bks /system/etc/security/cacerts.bks
>adb shell ls /system/etc/security/

Restart the AVD and try again.
>adb shell stop
>adb shell start

Much Better, the error message changed
Error Message:
POST: java.lang.NullPointerException
java.lang.NullPointException
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:83

Solution:
Maybe, that because I get the CER file by wrong way.
>echo | openssl s_client -connect api.local.sillycat.com:443 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > s1.pem


Import the PEM file again
>keytool -keystore cacerts.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -importcert -trustcacerts -alias s1 -file s1.pem -noprompt

Push the file again
>adb push cacerts.bks /system/etc/security/cacerts.bks

Restart the AVD
>adb shell stop
>adb shell start

But still not working.

It is not working for my project which is an old project. Maybe I can try in the newly project in the future.
I will just change the https to http on my local machine this time.

References:
http://www.bradcurtis.com/2011/02/13/hosts-file-google-android-emulator/
http://stackoverflow.com/questions/14109319/avd-emulator-browser-wont-use-hosts-file

http://stackoverflow.com/questions/5687082/obtain-root-access-via-su-on-the-android-emulator
http://allencch.wordpress.com/2012/02/29/learn-to-root-android-using-emulator/

http://androidsu.com/superuser/
http://www.bradcurtis.com/2011/02/13/hosts-file-google-android-emulator/

Disable SSL check based on HTTPCLIENT
http://blog.syedgakbar.com/2012/07/21/android-https-and-not-trusted-server-certificate-error/
Disable SSL check based on ksoap2
http://lanyan-lan.iteye.com/blog/1523821

http://blog.antoine.li/2010/10/22/android-trusting-ssl-certificates/

分享到:
评论

相关推荐

    docker-android-emulator, android仿真器的Docker 文件.zip

    docker-android-emulator, android仿真器的Docker 文件 docker-android-emulator运行 Android 模拟器最新 debianopenjdk 7Android SDK 24.3.4Android api正在运行 模拟器这里存储库为不同的SDK提供 模拟

    如何快速启动安卓模拟器(Android_Emulator)

    快速启动安卓模拟器(Android_Emulator)的方法 Android 模拟器是一种非常有用的工具,对于 Android 应用程序的开发和测试来说非常重要。然而,每次启动 Android Emulator 都需要等待很长一段时间,几分钟甚至十几...

    android terminal emulator.apk.zip

    在Android 5.1.1系统上,"android terminal emulator.apk"表现良好,用户可以顺畅地输入各种ADB命令,如"adb shell"进入设备的shell环境,执行"ls"查看目录内容,"cd"切换目录,"install"安装APK文件,甚至"push"和...

    android-emulator-webrtc

    android-emulator-webrtc 它包含一组React组件,可用于从浏览器与android模拟器进行交互。 它旨在与连接到正在运行的仿真器的一起使用。 有关如何运行可通过网络访问的仿真器的示例,请参见脚本。 npm install --...

    Android代码-android_emulator_hacks

    android_emulator_hacks We run android espresso instrumentation tests on bamboo. This worked extremely randomly due to a few issues that we've tried to solve with this app. Emulator startup: We start ...

    在Android Emulator上安装App Market-g

    在Android Emulator上安装App Market-g是一个常见的任务,特别是对于开发者和测试人员而言,他们需要在模拟器上体验和测试各种应用。这篇文章将详细介绍如何在Android Emulator中安装Market-g,以便获取更多的应用...

    ubuntu上在androidstudio中启动emulator闪退的解决方法

    在 Ubuntu 上 Android Studio 中启动 Emulator闪退的解决方法 在 Android Studio 中点击模拟器的启动按钮后,模拟器界面弹出后,又立刻闪退。这是非常常见的问题,本文将为大家分享 Ubuntu 上在 Android Studio 中...

    android执行shell命令

    4. **Android Terminal Emulator**:对于普通用户,可以在设备上安装终端模拟器应用,如Terminal Emulator for Android,直接在设备上输入并执行shell命令。 执行shell命令时,需要注意以下几点: - **权限**:...

    android emulator数据库文件查看软件

    标题中的“android emulator数据库文件查看软件”指的是在Android模拟器中用于查看SQLite数据库文件的工具。在Android系统中,SQLite是一种轻量级的、关系型的数据库,常用于存储应用程序的数据。开发者或测试人员...

    android emulator using command line

    ### 使用命令行操作Android模拟器:安装与卸载APK 在进行Android应用开发时,开发者经常需要在模拟器上测试应用。为了提高效率并减少手动操作,掌握如何通过命令行来安装或卸载APK是非常有用的技能。下面将详细介绍...

    emulator.exe(Android SDK tools下文件)

    **Android SDK中的emulator.exe详解** 在Android应用开发过程中,Android SDK(Software Development Kit)扮演着至关重要的角色。它提供了一系列工具,使得开发者能够在没有实际设备的情况下,通过模拟器(Android...

    Install-Android-Emulator-and-Eclipse.rar_android_android emulato

    在本文中,我们将深入探讨如何在Windows操作系统上安装Android Emulator和Eclipse,这两个工具是Android应用开发不可或缺的部分。Android Emulator允许开发者在没有物理设备的情况下测试和调试应用程序,而Eclipse则...

    AndroidAuto-Emulator(DHU)-For-Linux

    《Android Auto Emulator (DHU) for Linux:打造车载体验的新纪元》 在现代科技的快速发展中,Android Auto已经成为连接智能手机与车载信息娱乐系统的重要桥梁。为了满足开发者和用户在Linux平台上模拟Android Auto...

    Android-Terminal-Emulator.zip

    利用命令访问android系统底层linux shell 这软件是google play市场中的推荐软件,排名很靠前,值得技术人员一用. --------------------- Access your Android's built-in Linux command line shell Android Terminal ...

    android-emulator-1.4.jar

    官方版本,亲测可用

    安卓终端模拟器 Android shell APK

    安卓终端模拟器,绿色无广告,最好用的android shell This is the final version that includes support for Android 1.5 "Cupcake": Term-1.0.65.apk Note: This application used to be named "Android Terminal ...

    android-emulator-hypervisor-driver-for-amd-processors

    用于 AMD 处理器的 Android Emulator Hypervisor 驱动程序 适用于AMD处理器的Android Emulator Hypervisor驱动程序是用于加速的虚拟机管理程序。 它是通过将 KVM 移植到 Windows(Windows 7 或更高版本,64 位)而制...

Global site tag (gtag.js) - Google Analytics