# Error in Kotlin Android

# 1. Nullpoint Expection on array list

private var foodList: ArrayList<Food_Model>? = null
Food_List.add( Food_Model("1", "Pizza"))
1
2

Solution

When you call ArrayList<Post>(null), you'll get this problem. If your objectHashMap is null, or it contains no values, you'll have a null there. The compiler isn't really complaining about you having a null, it's complaining about the fact that you're passing it to the ArrayList() constructor.

(adsbygoogle = window.adsbygoogle || []).push({});

If you look at the JavaDoc for ArrayList, it states that the collection can't be null, or you'll get a NullPointerException:

var foodList = ArrayList<Food_Model>()
1

# 2.Error inflating class android.support.v7.widget.CardView

I solved this by adding updated cardview and appcompat on the app/build.gradle

dependencies { ... 
	implementation 'com.android.support:appcompat-v7:28.0.0' 
	implementation 'com.android.support:cardview-v7:28.0.0' 
	implementation 'com.android.support:recyclerview-v7:28.0.0'
	 }
1
2
3
4
5

Then rebuild the project

# 3.How to add an image to the “drawable” folder in Android Studio?

  • Right click on res, new Image Asset
  • On Asset type choose Action Bar and Tab Icons
  • Choose the image path
  • Give your image a name in Resource name
  • Next->Finish

# 4. Android - When attempting to add an image creates a blank image

You can't add it through the Android Studios interface (why is beyond my comprehension..). You need to go to the root folder of your project to ...\app\src\main\res\drawablesand copy the image into all of the respective hdpi, mdpi, xhdpi, etc folders. Then clean your project and they will appear.

# 5. Binary xml file line #0: error inflating class imageview

you have to see if your image has become drawable-v23 or v24 which might be higher than your mobile os level, Make sure to avoid creating drawable version image in project example In drawable folder ~> "ic_contact(v24)"

# 6. New App Release Fail : You upload an apk which is not signed with upload certificate :

 Upload failed

You uploaded an APK that is not signed with the upload certificate. You must use the same certificate. The upload certificate has fingerprint:

[ SHA1: blah ]

and the certificate used to sign the APK you uploaded have fingerprint:

[ SHA1: different blah ]

1
2
3
4
5
6
7
8
9
10

Solution : Delete the Release and Upload new one