0

I came across this strange problem while testing my app on a Galaxy S III. It works fine on other devices.

The subject class goes like this:

public class MyClass extends Service {

    public void onCreate() {
        super.onCreate();

        // do stuff
    }
}

Other people have had the same problem and it seems to be related to the built of the source code. However, I don't know how to solve this on Android Studio.


SOLVED

It appears that the cause of the problem where the camera2 APIs which were used in that class. Those APIs target Lollipop and above and for that reason the app was crashing trying to resolve the imports,even if at runtime I wasn't using any unavailable method (checking the build version of the device).
I'm not sure about the reason of this, but anyway moving the Camera2 implementation to another class fixed the problem.

Community
  • 1
  • 1
Alessandro Roaro
  • 4,665
  • 6
  • 29
  • 48

1 Answers1

0

Please check your build.gradle file.

android { compileSdkVersion 17

 sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    instrumentTest.setRoot('tests')
}

}

This should be the way sdk version should be defined, for further clarification please refer to http://www.vogella.com/tutorials/AndroidBuild/article.html

AndroCoder
  • 1,669
  • 1
  • 11
  • 5