Showing posts with label Android App Dev. Show all posts
Showing posts with label Android App Dev. Show all posts

Tuesday, 26 December 2017

unable to load scripts from assets 'index.android.bundle' on real device

When I was runing below run-android then, I was getting unable to load script from asset error on emulator as shown below:

sachin@sachin-E470:~/react-native/test1$ react-native run-android





Then, I ran below commands,

sachin@sachin-E470:~/react-native/test1$ mkdir android/app/src/main/assets

sachin@sachin-E470:~/react-native/test1$ react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

sachin@sachin-E470:~/react-native/test1$ react-native run-android

Below is the result screenshot.



But, Now problem is, when I am changing App.js, changes are not reflecting in emulator device.
Any help for the same???

Tuesday, 3 October 2017

dev/kvm not found in android studio development

I was facing 'dev/kvm not found' this issue. I was not able to launch emulator in android studio.

The I checked kvm in my system with below command:

$kvm-ok
sachin@sachin-E470:~$ kvm-ok
The program 'kvm-ok' is currently not installed. You can install it by typing:
sudo apt install cpu-checker

Then I ran below command:

sachin@sachin-E470:~$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Then I got :

sachin@sachin-E470:~$ sudo kvm-ok
INFO: /dev/kvm does not exist
HINT:   sudo modprobe kvm_intel
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
      and then hard poweroff/poweron your system
KVM acceleration can NOT be used

Then I did:

sachin@sachin-E470:~$ sudo adduser sachin kvm  --where sachin is my username of on computer

Then I restarted system-->wen tto Bios-->security-->virtualization
and enabled both options for intel virtualization.

then started computer.

KVM issue solved.


Happy learning!!!

Thursday, 28 September 2017

SQLiteLog - file unlinked while open: /data/data/ when update database version

Hi,

This is the common issue which is related when we upgrade db by copuing prebuilt db in apk file and forget to set the version in db file which we copy in the asset folder. Means :

We set the new version in DBHelper but our copying db is having the older version which we forgot. So, whenever we update the version in DBHelper file, open out db new db file in sqlite browser and run below comand in sqlite query editor:

First check which version:
PRAGMA user_version ; 

above line will give you the version having the DB which will be your last version.

Now, we need to increment it by 1 or whatever we set in DBHelper, We need to set that version number here: below is thee command for the same:

PRAGMA user_version = <new_version_number>; 

Thats it. Run your program. you will be good.


Saturday, 23 September 2017

Signed APK 'App not installed' issue in android evelopment

Hi,

I was able to install unsigned apk file but when I was making it signed apk, it was showing 'App not installed'. I tried many options but after too much time consumed, I found below one and now i am able to install signed apk.


Just go to the Settings --> Apps --> Click on your App. ---> In App info page at the action bar menu there will be an option called " Uninstall for All users " click that. Your app will be completely uninstalled and now you can try installing the new version with no issue. Hope this will help you

Hope it will help you.

Friday, 22 September 2017

Hex Opacity Values

100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5% — 0D
0% — 00

Wednesday, 20 September 2017

dev/kvm not found in android studio

I was facing 'dev/kvm not found' this issue. I was not able to launch emulator in android studio.

The I checked kvm in my system with below command:

$kvm-ok
sachin@sachin-E470:~$ kvm-ok
The program 'kvm-ok' is currently not installed. You can install it by typing:
sudo apt install cpu-checker

Then I ran below command:

sachin@sachin-E470:~$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Then I got :

sachin@sachin-E470:~$ sudo kvm-ok
INFO: /dev/kvm does not exist
HINT:   sudo modprobe kvm_intel
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
      and then hard poweroff/poweron your system
KVM acceleration can NOT be used

Then I did:

sachin@sachin-E470:~$ sudo adduser sachin kvm  --where sachin is my username of on computer

Then I restarted system-->wen tto Bios-->security-->virtualization
and enabled both options for intel virtualization.

then started computer.

KVM issue solved.

Happy learning!!!





Wednesday, 6 September 2017

Can't unfold 'data' folder in Android Device Monitor

I have faced this issue. I have tried many ways but no luck. I was able to insert and read data but was not able find SQLite db file under data folder in Android Device Monitor.

When I was running below command, I was getting below error:
$ adb devices
List of devices attached
adb server is out of date.  killing...
* daemon started successfully *


I have followed below steps :

1. Go to your platform tools path. in my system, it is: /Android/Sdk/platform-tools>

2. run below commands:

it000483@IND-PUN-LAP-183:~/Android/Sdk/platform-tools$ adb kill-server
it000483@IND-PUN-LAP-183:~/Android/Sdk/platform-tools$ adb start-server
it000483@IND-PUN-LAP-183:~/Android/Sdk/platform-tools$ adb root



Now, I am able to see the files in ADB:



IF ABOVE TRICK NOT WORKING, and if you are getting adb out of date,

copy /Android/Sdk/platform-tools/adb file to /usr/bin folder . i.e. replace old /usr/bin/adb with new adb

Also, Check for emulator image, If you have google play type image, you need to take google api image to get root access.

Use --> Google APIs Intel x86 Atom System Image   NOT Google Play Intel x86 Atom System Image

Then use, $adb root, it should work, you can view files in android device monitor.

Hope this will work for you. 



Saturday, 26 August 2017

Passing data on button click

When we add data in editText aand click on button, we will show this data on plainText.

Code as shown below:


Toggle and If-Else in android app

When button is ON, we are getting the corresponding message as shown below:


TextView value change in another view in android app

in android project, there is string.xml under res/values folder. we use this 'strings.xml' to store variable properties:

add below new name in strings.xml

<string name="string_value1">Value from strings.xml</string>


Now, add textview and render strings.xml name - value in this texview



Now, lets change the value of TextView from java code:




One Activity To another Activity in android app

When we click on button, we should go to another activity. Lets use existing project.

add second activity on button listenerL

clickButton.setOnClickListener(new View.OnClickListener() {
    @Override    public void onClick(View view) {
        //Toast.makeText(getApplicationContext(),"You just clicked button",Toast.LENGTH_LONG).show();        Intent intent = new Intent(MainActivity.this,SecondActivity.class);
        startActivity(intent);
    }
});




Now add second activity:

right click on res folder and create SecondActivity:

New--> Activity--> Empty Activity



When we run code as shown below,




When we click on 'CLICK ME' button, below second activity comes:



Button Click Activity in android app

Button Click Activity in android app





create the androd project, Please refer my previous article first android hello world app.

I have changed the theme as of below:




Lets add one button and add click event listener:




Now, add code in java file to handle button click event:



To add Action bar in the app:



To add backgraound image in app:

Copy required image in res/drawable folder:



Its done!!!!
















First Android Hello World app


















Installing Android Studio in Linux/Ubuntu

For android app devlopment, we need Andrioid Studio, it acts as a android app development IDE like eclipse, intelliij etc.

Install Android studio for Ubuntu:

1. First install java 8.
To install Java8, use below commands from linux terminal:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
After that
sudo apt-get install oracle-java8-set-default


2. Now install Android studio.
We can do it with 2 ways.
    A. By downloading and unzipping android studio files.

Installing Android Studio

  1. Download Android Studio from here, use All Android Studio Packages
  2. Extract the archive file into an appropriate location for your applications, eg: /opt. Use the filename of your downloaded archive, in my example android-studio-ide-141.2178183-linux.zip
    sudo unzip android-studio-ide-141.2178183-linux.zip -d /opt
  3. To launch Android Studio, navigate to the /opt/android-studio/bin directory in a terminal and execute ./studio.sh. Or use a desktop file, see below.
    You may want to add /opt/android-studio/bin to your PATH environmental variable so that you can start Android Studio from any directory.

Create a desktop file

Create a new file androidstudio.desktop by running the command:
nano ~/.local/share/applications/androidstudio.desktop
and add the lines below
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec="/opt/android-studio/bin/studio.sh" %f
Icon=/opt/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=android-studio


B. By linux command terminal

Using ubuntu-make
Ubuntu Make is a command line tool which allows you to download the latest version of popular developer tools on your installation, installing it alongside all of the required dependencies (which will only ask for root access if you don't have all the required dependencies installed already), enable multi-arch on your system if you are on a 64 bit machine, integrate it with the Unity launcher. Basically, one command to get your system ready to develop with!




sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt update
sudo apt install ubuntu-make

For Ubuntu 15.10 and up
Ubuntu Make is already in official repositories, run :
sudo apt install ubuntu-make
Note that umake version should be 16.05 to be able to download android studio, check by running
umake --version
If not, use the Ubuntu 14.04 method to install it.

I am seeing in my system,

it000483@IND-PUN-LAP-183:~$ umake --version
17.03
It means, umake is installed with version 17.03 version

Then  use below commands for 

$umake android --accept-license












Its done.











Extract error records while inserting into db table using JDBCIO apache beam in java

 I was inserting data into postgres db using apache beam pipeline. it works perfectly with JdbcIO write of apache beam library. But, now, i ...