I am making a sample Spen SDK app for my Samsung Note 3.0 and am using Android Studio. The relavant xml file is:-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/settingBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="pen"
android:layout_weight="1"/>
<Button
android:id="@+id/eraseBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="erase"
android:layout_weight="1"/>
<Button
android:id="@+id/undoBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="undo"
android:layout_weight="1"/>
<Button
android:id="@+id/redoBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="redo"
android:layout_weight="1"/>
</LinearLayout>
<FrameLayout
android:id="@+id/canvas_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.samsung.sdraw.CanvasView
android:id="@+id/canvas_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"
/>
<com.samsung.sdraw.SettingView
android:id="@+id/setting_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
And the corresponding java code is:-
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MainActivity mContext = this;
CanvasView mCanvasView = (CanvasView) findViewById(R.id.canvas_view);
RelativeLayout mCanvasContainer = (RelativeLayout) findViewById(R.id.canvas_container);
SCanvasView mSCanvas = new SCanvasView(mContext);
mCanvasContainer.addView(mSCanvas);
}
Now when I try to debug the app by connecting Samsung Note 3.0 to PC, the app launches, shows the mainPage and crashes within a second. I searched on the net and found this and this. I too didn't have armeabi directory of Spen SDK in the libs folder. So, I included the libraries and now my project's libs folder looks like:-
libs <-- my Project's folder
libs
armeabi
libspen23.jar
libspen23_multiwindow.jar
But still the same thing is happening. There is no compile error. One thing that I then noticed was that my xml file could not be rendered by the Android Studio. Following is the screenshot:
The exeptions are:- The following classes could not be instantiated:
- com.samsung.sdraw.CanvasView (Write access not allowed during rendering(\mnt\sdcard\android\data\null\serial) )
- com.samsung.sdraw.SettingView(java.lang.NullPointerException )
Can anyone tell me what thw problem is?
UPDATE:
I have debugged the app and exception occurs at
setContentView(R.layout.activity_main);
in OnCreate(). But I can't find out why is the app crashing there.
- The gradle file is:-
apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion '19.1.0' defaultConfig { applicationId 'com.example.myapplication3.app' minSdkVersion 9 targetSdkVersion 19 versionCode 1 versionName '1.0' } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile files('libs/libspen23.jar') compile 'com.android.support:appcompat-v7:19.+' compile files('libs/libs/libspen23.jar') }
- The app runs if I comment the CanvasView and SettingsView blocks from xml file and the corresponding lines from OnCreate() function.