I don't know why but I am getting this ![Log Cat][1] when trying to make an app that vibrates the phone after pressing a button, following the class Udemy Vibrate App. I have aready tried to clean, close the program and check if Android Private Libraries is selected (it is). I also gave permission to the phone to vibrate in the manifest file.
12-15 16:36:37.956: E/AndroidRuntime(24903): FATAL EXCEPTION: main
12-15 16:36:37.956: E/AndroidRuntime(24903): Process: com.example.vibrate, PID: 24903
12-15 16:36:37.956: E/AndroidRuntime(24903): java.lang.RuntimeException: Unable to instantiate
activity ComponentInfo{com.example.vibrate/com.example.vibrate.Vibrate}:
java.lang.ClassNotFoundException: Didn't find class "com.example.vibrate.Vibrate" on path:
DexPathList[[zip file "/data/app/com.example.vibrate-3.apk"],nativeLibraryDirectories=[/data/app-
lib/com.example.vibrate-3, /vendor/lib, /system/lib]]
This is the program:
package com.example.vibrate;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class VibrateActivity extends Activity implements OnClickListener {
private Button vibrateButton;
private Button rhythmButton;
private Button stopVibrationButton;
private Vibrator vibrator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vibrate);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrateButton = (Button) findViewById(R.id.vibrate);
rhythmButton = (Button) findViewById(R.id.rhythm);
stopVibrationButton = (Button) findViewById(R.id.stop_vibration);
vibrateButton.setOnClickListener(this);
rhythmButton.setOnClickListener(this);
stopVibrationButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.vibrate:
vibrator.vibrate(1000);
break;
case R.id.rhythm:
long[] pattern = { 250, 500 };
vibrator.vibrate(pattern, 0);
break;
case R.id.stop_vibration:
vibrator.cancel();
break;
}
}
}
And this is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vibrate"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Vibrate"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I appreciate any help. Thanks!