Search code examples
androidandroid-activityandroid-compatibility

Android resource not found on some devices


Have an issue when running an app built with android studio (2.0 p4) on a Note 5. To clarify this works perfectly on emulator and other devices. The app in the example is just the default "empty" app, having the exact same error as the app we are building

Following code:

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

Throws following exception (on Note 5):

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.note5test/com.test.note5test.MainActivity}:
 android.content.res.Resources$NotFoundException: Resource ID #0x7f020016

R file:

public static final int abc_ic_ab_back_mtrl_am_alpha=0x7f020016;

If I just change to extend Activity (instead of AppCompatActivity) it works though, but I need to use the action bar so that is not an option.

Spent too much time on this now... Any clues?


Solution

  • Found the issue, it was because I had an old version of the build tools, the version I used didn't handle resources correctly, so just updating to a new version made it all work.