I'm new with android development. I'm currently developing an Android Application on Face Recognition. I'm trying to run an existing source code that I obtain from github. The codes seems does not have any error(red line beneath the code). When I tried to run, the application has stopped working and gave me a java.lang.NullPointerException error.
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:98)
at com.example.syafiq.testing.FdActivity.onCreate(FdActivity.java:179)
on the highlighted error (FdActivity.java:179)
(line 178) ActionBar actionBar = getActionBar();
(line 179) actionBar.setDisplayHomeAsUpEnabled(true);
I've tried solution that I've found on the Internet
First try:
ActionBar actionBar = getActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
And yet still the same error, so i tried another one that I found on the Internet.
Second try:
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
The result still the same
I've tried the third one
Third try:
ActionBar actionBar = getActionBar();
Objects.requireNonNull(actionBar).setDisplayHomeAsUpEnabled(true);
All the three solution that I've tried still giving the same error, point to line 179
For android manifest.xml(obtain from source code on github):
android:theme="@android:style/Theme.Holo"
But the source code does not have style.xml file under the values folder. But my android studio include with style.xml file and the code is:
<style name="Theme.Holo" parent="Theme.AppCompat.Light.DarkActionBar">
I did not use the import tools instead I've created manually (.java, .xml and other libraries that included)