Android extension can't find argfree method error

W

Wraithious

Guest
Hi,
I am working on making a text to speech android extension for gamemaker studio, I'm getting this error: 05-01 17:16:41.304 16939 17013 I yoyo : Can't find argfree method on extension class:getMic [] when trying to use my extension in-game. the game doesn't crash, it just can't find anything in the extension. So what exactly is an argfree method?

I also tried tried changing the onCreate method to a public method and calling it from GM:S and several other things but no luck. Here is the relevant code, if you need more info please ask.

this part of the java class TtsStt is causing the error when called:
Code:
protected void onCreate(Bundle savedInstanceState) { //HERE is where I tried replacing
//protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
//with just public void initTTS() {...} but got same error  
   super.onCreate(savedInstanceState);
   setContentView(R.layout.tts_stt);
   preferences = getSharedPreferences(PREFS,0);
   editor = preferences.edit();
   editor.putString(TSTYLE, "military time").apply();
   RunnerActivity.CurrentActivity.findViewById(R.id.microphoneButton).setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           listen();
       }
   });
   loadQuestions();
   tts = new TextToSpeech(RunnerActivity.CurrentActivity, new TextToSpeech.OnInitListener() {
   @Override
       public void onInit(int status) {
           if (status == TextToSpeech.SUCCESS) {
               int result = tts.setLanguage(Locale.US);
               if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                   Log.i("yoyo", "This Language is not supported");
               }
               speak("Hello");
           } else {
               Log.i("yoyo", "Initilization Failed!");
           }
       }
   });
}
public void getMic() {
           listen();
}


private void listen(){
   Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
   i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
   i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
   i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something");
   try {
       RunnerActivity.CurrentActivity.startActivityForResult(i, 100);
   } catch (ActivityNotFoundException a) {
     Log.i("yoyo", "Your device doesn't support Speech Recognition");
   }
}
in the activity level In my manifest I have injected this:
Code:
<activity android:name="${YYAndroidPackageName}.TtsStt"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:label="@string/app_name" >
       <intent-filter>
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
   </activity>
           <category android:name="android.intent.category.LAUNCHER" />
       />
   />
and injected the gradle dependencies in the manifest:
Code:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
 
W

Wraithious

Guest
Well it's partially solved, I replaced protected void onCreate to public void onCreate and it worked, but only for the create event but none of the rest of the code gets executed and returns the game to GMS. :( I think the reason may be the rest of the methods in the java file all start with private void, OR the other explanation may be that the intent that gets run in the onCreate method sends an internal async event on the java side of the code and onActivityResult isn't being picked up to go back to the extension, can anyone here that makes extensions give me any ideas on this?
 

zbox

Member
GMC Elder
This usually means there is an exception being thrown. I did a partial implementation and I ran into the same problem, just needs a little more debugging :)
 
W

Wraithious

Guest
This usually means there is an exception being thrown. I did a partial implementation and I ran into the same problem, just needs a little more debugging :)
Cool thanks! I'm working on it, I may have to set up my intents all in one shot like you have to do with the sendBroadcast Intent, normal intents you can define and set up like normal then use RunnerActivity.CurrentActivity.startActivity(intent) but you're right, the debugging along with log.i yoyo is your friend! haha, but it really is, I have found this so far in the log:
Code:
05-01 22:53:30.464  1781  1865 I yoyo    : Text input to speak accepted- what time is it
05-01 22:53:30.464  1781  1865 I yoyo    : Can't find method on extension class:null
which is very interesting and must mean the next method is breaking away from the RunnerActivity.CurrentActivity because look at where I put the log.i:
Code:
public void speak(String text){  //was private
            Log.i("yoyo", "Text input to speak accepted- " + text);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, null);
        }else{
            tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
        }
    }
wich is called simply from gms with:
Code:
speak("what time is it");
 

zbox

Member
GMC Elder
Yeah well from the looks of that the speak() function on the tts class is what is making it fail. Never ended up completing mine, the client stopped replying so I didn't finish the implementation. Shame, could have some nice uses :) good luck!
 
W

Wraithious

Guest
@zbox Thanks I see what you mean this isn't easy to say the least, I can get the microphone to work but it just silently returns to the GMS side without saying anything after you speak, but there has to be a way, Android says it can only work when referenced to an object created in the java class so it's multiple trial and error, so I'll keep trying. it works great in android ****** but I hate making games in java thats why I use GM: S :)
 
Top