Showing posts with label Android Studio. Show all posts
Showing posts with label Android Studio. Show all posts

19 September 2018

Start Android Studio in Ubuntu with root privileges

If you have to start Android Studio in Ubuntu with root privileges for regular updates, you should make these commands in terminal:

sudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/studio
sudo chmod 777 /usr/local/bin/studio

If you have problem with sudo in Ubuntu you can setup root password with command:

sudo passwd root

Now you can start android studio from anywhere by entering command : studio

06 September 2018

Relocate Android Studio SDK and Emulator files

If you want to relocate your Android Studio SDK and Emulator files to different folder or disc, than you have to setup these environment variables :

ANDROID_SDK_HOME                        - D:\Android
ANDROID_EMULATOR_HOME          - D:\Android\.android\
ANDROID_AVD_HOME                        - D:\Android\.android\avd\

After these setup variables, your Android Studio will use these folders.


04 September 2018

Android SQL Injection Vulnerability with exported=false

So here's the problem: when I add the widget to the homescreen, a SecurityException is immediately thrown inside the onDataSetChanged() method when I try to query the provider. This appears to be because the homescreen does not hold the permission to read my content provider.

Because of Google Play Developer Console witch refuse App Submission because of  SQL Injection Vulnerability with exported=false in AndroidManifest.xml, we need to leave that option to false.

While the context is actually correct, it is bound to the wrong process.

So we need to enclose our query in clearing Identiry Token in WidgetService.java:

// Revert back to our process' identity so we can work with our
// content provider
final long identityToken = Binder.clearCallingIdentity();

mCursor = cr.query(EntryColumns.ALL_ENTRIES_CONTENT_URI, new String[]{EntryColumns.TITLE, EntryColumns._ID, FeedData.FeedColumns.ICON}, selection.toString(), null, EntryColumns.DATE + Constants.DB_DESC);

// Restore the identity - not sure if it's needed since we're going
// to return right here, but it just *seems* cleaner
Binder.restoreCallingIdentity(identityToken);

This solves the problem, even without setting read/write permissions on the contentprovider, just using it with exported set to "false".

25 June 2018

Google Play warning: Your app contains a SQL Injection issue

If you get Google Play warning on your Google Play Developer Console, than maybe there is simple solution. In your AndroidManifest.xml file just set :

<provider
        android:exported="false"
/>

and than recompile project, rebuild APK, and reupload new version to Google Play Developer Console.

01 December 2017

Android Emulator does not Launch in Ubuntu 17.10

I tried to run the Android Studio 3 emulator on fresh installed Ubuntu 17.10 to test an app I'm working on. And I got this error in Android Studio Event Log:

libGL error: unable to load driver: i965_dri.so
AVD Emulator: Process finished with exit code -1


Solution:
Type in Terminal:

$ cd ~/Android/Sdk/emulator/lib64/libstdc++
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

That's it!



Now my Android Studio 3 emulator is working again!

06 September 2017

Android SDK emulator - GPU driver issues

If you have an Intel HD Graphics running the Android SDK emulator in slow software mode, it's intended that a compatibility OpenGL renderer is not used.


I'm sorry about it, but we need to be able to switch to better-supported Intel GPU drivers especially when running high API levels (25+) of system images. Intel iGPUs of that generation (and older) have many issues with OpenGL compatibility.

You could try in terminal:

emulator -list-avds
emulator -avd <AVD_NAME> -gpu host


but that is not permanent fix.

Real resolution to this problem is fine tune the Android emulator with next procedure:

If you'd still like to use the native OpenGL renderer on a Intel HD GPU (at your own risk), go to :

Settings (in Android emulator)
section: General

option: OpenGL ES renderer (requires restart)
select: ANGLE (D3D9)

option: OpenGL ES API level (requires restart)
select: Compatibility (OpenGL ES 1.1/2.0)

and restart your Android emulator in HAX fast virtual mode with hardware rendering...

Source: Google Issue Tracker - Discussion : GPU driver issue

09 September 2015

How to setup Windows Android Intel HAXM AVD Emulator

This is how to setup Windows 7, 8, 8.1 and 10 for Android Intel HAXM AVD Emulator.

In Administrator Command Prompt (Win+X) type:

C:\>bcdedit /copy {current} /d "No Hyper-V" 
The entry was successfully copied to {ff-23-113-824e-5c5144ea}. 

C:\>bcdedit /set {ff-23-113-824e-5c5144ea} hypervisorlaunchtype off 
The operation completed successfully.

P.S.:
In order to access the new boot menu, I select Settings (Windows Key + C) then Power, and Restart but hold down shift on the keyboard while clicking Restart with the mouse.

24 May 2015

How Do I Connect an Android Wear Emulator to a Real Phone ?

After starting Android Wear emulator and connected Real Android Phone :

- start Android Wear App on Real Android Phone and connect to Android Wear Emulator, or

- just type in PC Terminal :

adb -d forward tcp:5601 tcp:5601

Source: http://www.tech-recipes.com/rx/49586/how-do-i-connect-an-android-wear-emulator-to-a-real-phone/