Closed bdfcommunication closed 6 months ago
That method is in a trait that GoogleAdsClient
imports, so it should be available.
How did you update your code up to this point? If you run composer update
, it should update everything at once, including GoogleAdsClient
and ConfigurationTrait
.
Just having the same error here in V14 when using: $googleAdsServiceClient = $this->googleAdsClient->getGoogleAdsServiceClient();
Composer is fully updated. ConfigurationTrait is also in the folder.
Here's the error: Uncaught Error: Call to undefined method Google\Ads\GoogleAds\Lib\V14\GoogleAdsClient::useGapicV2Source() in /var/www/admanager.reweb.com.br/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V14/ServiceClientFactoryTrait.php:1294
I tried adding the function to the ConfigurationTrait.php on /main/src/Google/Ads/GoogleAds/Lib/ConfigurationTrait.php, that no, it didn't have that line, and everything worked like a charm. If you notice, the file ConfigurationTrait.php you have from V13 and the one on github Link are different exactely on that method. I don't understand why composer does not update that but adding the method by hand solved the thing for me.
Thanks @bdfcommunication !
I take it that you can resolve this problem, so I'm closing this issue now. Feel free to open it if you still encounter this issue.
I was checking and the function useGapicV2Source is already in ConfigurationTrait.php, so I'm not sure about that move. Besides, I don't know if changing vendor files is a good definitive 'solution'. I see that from V13 from V14 a lot of calls to $this->useGapicV2Source() are included in ServiceClientFactoryTrait.php . Maybe there's a bug @fiboknacky ?
Besides, I don't know if changing vendor files is a good definitive 'solution'.
I'm not sure what you meant, but to properly upgrade the dependencies, you should always run composer update
at the root of your project.
If you're unsure, you can just remove vendor
and composer.lock
and run composer update
again. Could you please try doing so?
In the V15 api version there is a bug. OS: Debian 11 64Bit. PHP 8.0. Every other packet installed and up to date!
While the class ServiceClientFactoryTrait makes massive use of the call $this->useGapicV2Source(), the method seems not to be implemented anywhere.
Once correctely created the client by: $googleAdsClient = (new GoogleAdsClientBuilder())->fromFile() ->withOAuth2Credential($oAuth2Credential) ->withLoginCustomerId($loginCustomerId ?? $rootCustomerId) ->build(); The call: $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
will result in fatal php error
Fatal error: Uncaught Error: Call to undefined method Google\Ads\GoogleAds\Lib\V15\GoogleAdsClient::useGapicV2Source() in directory../google-ads-api/src/Google/Ads/GoogleAds/Lib/V15/ServiceClientFactoryTrait.php:1337
The problem is simply solved by adding the method to the class GoogleAdsClient returning its setted value from the constructor so that GoogleAdsClient should seems should be:
class GoogleAdsClient { use ServiceClientFactoryTrait;
//missing method // public function useGapicV2Source() { return $this->useGapicV2Source; } }
I know it is not a great deal but it can make you loose a lot of time, especially if you are not an expert and you update using composer and expect everything that worked to work again.
Sincerely