-1
私はOpenSLESというアンドロイドのndkライブラリで作業しようとしています。 soundPlayerクラスを呼び出そうとすると、メソッドが見つからないのですが、githubのNativeAudioの例を見て、すべて正しいことをしているか、何かをスキップして見つけられません。Android NDK、JavaのCメソッドを呼び出せません
私はネイティブ-LIB-jni.cファイルに次の方法があります(それが動作するようにActivity
を実装する必要がある場合、私は知らない私にはない
// create the engine and output mix objects
void
Java_com_example_gebruiker_DrumIORemastered_soundPlayer_createEngine(JNIEnv*
env, jclass clazz)
{
SLresult result;
// create engine
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the engine interface, which is needed in order to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// create output mix, with environmental reverb specified as a non-required interface
const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
const SLboolean req[1] = {SL_BOOLEAN_FALSE};
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// realize the output mix
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the environmental reverb interface
// this could fail if the environmental reverb effect is not available,
// either because the feature is not present, excessive CPU load, or
// the required MODIFY_AUDIO_SETTINGS permission was not requested and granted
result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
&outputMixEnvironmentalReverb);
if (SL_RESULT_SUCCESS == result) {
result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties(
outputMixEnvironmentalReverb, &reverbSettings);
(void)result;
}
// ignore unsuccessful result codes for environmental reverb, as it is optional for this example
}
が私のクラスはSoundPlayer
呼ばれているのですか?そう右だと思う)
マイCMakeLists.txt
:?
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall")
add_library( native-lib-jni
SHARED
C:/Users/Gebruiker/AndroidStudioProjects/DrumIORemastered/
app/src/main/cpp/native-lib-jni.c)
include_directories(C:/Users/Gebruiker/AndroidStudioProjects
/DrumIORemastered/app/src/main/cpp)
target_link_libraries(native-lib-jni
android
log
OpenSLES)
と私のAndroidManifest
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gebruiker.drumioremastered">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".drumPlayerActivity">
android:screenOrientation="portrait"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
here is my drumplayer :
package com.example.gebruiker.drumioremastered;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import com.example.gebruiker.drumioremastered.eventbus.MessageEvent;
import com.example.gebruiker.drumioremastered.utilities.playButton;
import org.greenrobot.eventbus.EventBus;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class drumPlayerActivity extends AppCompatActivity {
@BindView(R.id.playButton1)
playButton mplayButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
@OnClick(R.id.playButton1)
public void playClicked(){
mplayButton.changeButtonstate();
EventBus.getDefault().
post(createStateMessage(mplayButton.getButtonState()));
}
public MessageEvent createStateMessage(boolean buttonState){
MessageEvent message = new MessageEvent();
if(buttonState){
message.setPlayerState(true);
mplayButton.setText("Play");
}
else{
message.setPlayerState(false);
mplayButton.setText("Stop");
}
return message;
}
ショー 'drumPlayerActivity' – nikis
が追加' native'メソッドが宣言されたJavaクラスは 'com.example.gebruiker.drumioremastered.SoundPlayer'は、なぜあなたは'あなたの中にcom_example_gebruiker_DrumIORemastered_soundPlayer'を持っていないされている場合は – trOnk12
上記参照C関数名? (ケースの違いに注意してください) – Michael