Skip to main content
AMRAudioRecorder can be integrated into your Android project in two ways: as a module or by copying the source file directly. If you’re using Android Studio, the easiest way to use AMRAudioRecorder is to import it as a module.
1

Download the library

Clone or download the AMRAudioRecorder repository:
git clone https://github.com/rayliverified/AMRAudioRecorder.git
2

Import the module

In Android Studio:
  1. Go to File > New > Import Module
  2. Navigate to the amraudiorecorder directory
  3. Click Finish to import the module
3

Add module dependency

Add the module to your app’s build.gradle file:
build.gradle
dependencies {
    implementation project(':amraudiorecorder')
    // ... other dependencies
}
4

Sync your project

Click Sync Now when prompted, or run:
./gradlew sync

Method 2: Copy source file

For other IDEs or if you prefer to include the source directly, you can copy the AMRAudioRecorder.java file into your project.
1

Locate the source file

Find AMRAudioRecorder.java in the repository:
amraudiorecorder/src/main/java/com/water/amraudiorecorder/AMRAudioRecorder.java
2

Copy to your project

Copy the file to your project’s source directory, maintaining the package structure:
your-app/src/main/java/com/water/amraudiorecorder/AMRAudioRecorder.java
Or update the package name to match your project structure.
3

Verify the import

Ensure you can import the class in your code:
import com.water.amraudiorecorder.AMRAudioRecorder;

Required permissions

AMRAudioRecorder requires audio recording and storage permissions. Add these to your AndroidManifest.xml:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourapp.package">
    
    <!-- Required permissions -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
    <application
        ...>
        ...
    </application>
</manifest>
On Android 6.0 (API level 23) and above, you must request these permissions at runtime. See the Quickstart guide for an example.

Verify installation

Create a test activity to verify the installation:
MainActivity.java
import com.water.amraudiorecorder.AMRAudioRecorder;
import android.os.Environment;
import java.io.File;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Create a directory for recordings
        String sdcardPath = Environment.getExternalStorageDirectory().getAbsolutePath();
        String recordingDirectory = sdcardPath + "/recordings/";
        File dir = new File(recordingDirectory);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        
        // Initialize the recorder
        AMRAudioRecorder recorder = new AMRAudioRecorder(recordingDirectory);
        
        // If this compiles successfully, installation is complete
    }
}
The directory path you provide must exist before creating an AMRAudioRecorder instance. The library will throw an IllegalArgumentException if the directory doesn’t exist or isn’t valid.

Next steps

Quickstart

Learn how to record your first audio file with AMRAudioRecorder